Dynamically switching receive locations between database servers - biztalk

Using BizTalk I need to read data from one of two databases that are hosted in Unix using ODBC.
The data is replicated between the databases and if one of the databases does not respond I need to switch to the other. There is no load balancer or anything so I need to be able to do the switch on the BizTalk server.
I was thinking of creating two receive locations, one for each database server, only one of them enabled and then have a Windows service that periodically tries to make a connection to one of the database servers and if there is an exception, call a powershell script that disables the receive location for the server that does not respond and enable the other receivelocation.
Is there a better solution for this?

I would solve this as follows:
In Biztalk create a single http receive location.
Create a windows service
In the windows service poll the first database, if it does not respond poll from the second database
Have the Biztalk service post the information to the http receive location
You need to consider what happens if you read the same data twice, once from the main database and once from the backup.

Related

Linked Servers in SQL Database Managed Instance

In a SQL Server Managed Instance I have 2 databases (for security reasons both databases have different logins). I need the possibility to allow one database to look into the other one. In a local SQL Server I was able to create a Linked Server to realize this. But this seems not to work using the Managed Instance.
Can someone give some hints how to achieve this?
Managed Instance supports linked servers (unless if they use MSDTC for some distributed writes). Make sure that you add logins for remote server:
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'PEER',#useself=N'False',#locallogin=NULL,
#rmtuser=N'$(linkedServerUsername)', #rmtpassword='$(linkedServerPassword)';
If it still doesn't work put the exact error message. This might be Network security Group blocking the port, VNets that are not peered, etc.

Oracle binding not showing in send port

I have a very simple BizTalk application that is polling the records from a SQL server and does some transformation then save it to the Oracle DB. I used BizTalk 2010, SQL server 2012, Oracle 11g each is hosted on their own separate server. BizTalk was setup properly and has been working fine.
I have attached the orchestration diagram for clarity. Nothing fancy, I have set up the sending and receiving port successfully (can connect to all the database, and I used typedpolling for inbound and insert operation for the outbound. The project can be compiled and deployed successfully.
I have imported the bindings to BizTalk Admin Console and can see both bindings on the receive port and send port. The following image shows the bindings for send port is there.
However, when I tried to configure the Orchestration, I can only see the receive Ports in the selection but the send ports information is not available for me to pick.
From my limited exposure to BizTalk in the past, I can select the send port once I have imported the bindings to the console. I wonder what I have done incorrectly this time?
Usually a table operation such as an insert will be a request (the insert) and the response which shows it has succeeded (with an array/list of ID's of the new records). If you look the port that was created from the bindings you will see both a Send pipeline and a Receive Pipeline. Just make the port in the Orchestration a Request/Response, and consume the response (even if you don't do anything with it). Then you can bind the logical port the the actual port one as the logical port will then match the port.

Java Web application getting Cannot create PoolableConnectionFactory DB2 SQL Error: SQLCODE=-1776 for HADR configured on DB2

I have developed a web application where in i've configured two <Resource> with proper parameters in server.xml of Apache tomcat server, Using JNDI connection pool. Among two resource tags in server.xml, first tag is having details of primary server and another tag contains the details of standby server. My idea is if i dont get connection from primary for certain time, I'll switch the datasource to standby and run the query from servlet. But when I ran the code, It gave me the error Cannot create PoolableConnectionFactory (DB2 SQL Error: SQLCODE=-1776, SQLSTATE= , SQLERRMC=1, DRIVER=3.57.82)
I googled lot but cant find any concrete answer about this, but one thing was common in all i.e. HADR(Hisgh Availability Disaster Recovery) configuration of DB2 server.
Please help me out.
Generally speaking, you cannot connect to the standby database unless it assumes the primary role after the take-over.
The correct way of setting up a DB2 HADR cluster is to configure a virtual IP address in your cluster management software that gets assigned to the new primary database after the take-over; while the change remains completely transparent for client applications.
You'll need to talk to your DBAs to learn how to configure the application.
In a HADR configuration, each time the database flips from primary to standby and the standby to primary, the Server will send ClientReroute Exception to each client connected to DB2 server, So I've caught it programtically and and tried the transaction again and it succeeded.

Multiple connections on a single .mdf database (ASP.net) SQL Server

I'm trying to place a .mdf database on a Computer A and access it simultaneously on Computer B but I'm having an error that says I cannot access the mdf file because it's being used by another process.
The setup is, the database is hosted on a Public folder in Computer A. I have Visual Studio running on both computers, and Computer B accesses the database on Computer A.
Computer A Connection path string:
C:\Users\Public\database.mdf
Computer B Connection path string:
\192.168.254.8\Public\database.mdf
Is there some sort of setting that I do not know of to enable multiple access on a db? Or this is not possible?
EDIT:
Let me rephrase my question, sorry.
There are two computers connected via a network, and I want to access one Visual Studio solution/project website. I wanted to do this as a demonstration, is it possible?
You should have an instance of SQL Server (even express) running on the host machine.
All requests from the clients should use the standard mechanisms for connecting to that server instance. In other words, they won't run their own copy of SQL Server, instead they will connect to the instance running on the host machine.
Simultaneous or direct access to Database files under any DBMS control either a very bad practice or simply impossible.
Use proper DBMS tools to access the data.
And yes - its possible to access Web site project for demo.
Install SQL Server on the host machine (the one that you want to keep your database on).
Then in Visual Studio, use the "Server Explorer" to locate the remote instance of the database. From there, you can utilize the remote instance of SQL Server in your connection string, thus allowing you to connect multiple computers to a single database.
Using two instances of SQL Server to connect to the single .mdf file is a very bad practice.
Instead of specifying the MDF file in your connection string (which, I believe, uses a form of User Instancing), you should use SQL Server Management Studio (SSMS) to attach the MDF. Then connect to SQL Server, rather than to the MDF.
You may need to move the MDF and LDF files to a place where the SQL Server identity can access them, rather than keeping them in your VS project.
Most projects keep scripts to create the DB in their VS project, but not the binary MDF itself.
When you deploy, the process is similar: use SSMS to attach the MDF on your server.
Yes, If 2 or More Computers are connected by networks like LAN You can access the Database Database1.mdf (say) from another SQL Server by entering its user name / Password /by Visual studio connection.
Disadvantages:
If more than 7~8 systems are accessing same Database same time System response slows down and Hangs up or may result error like connection pool exceeded or Device not responding..
In Big Companies they use Huge Multi-core & Multi-Processer based sever which will respond faster.
Overcome: while writing Applications Use Connection Open and Close Particularly while executing the SQL queries in other time it should be closed.
Best Programer uses Transaction instead of using normal methods. Transaction Makes Every User Access Database With valid and successful Execution of queries. These Queries (Transaction Queries) mainly executes on client machine and later updates the same over Main server when it got Time slot for it(synchronize).

Sending files from server to client with ASP.NET

I am developing a C# ASP.NET 4.0 application that will reside on a Windows Server 2003. By mean of accessing this application through a network computer, any user would be able to upload files to the windows server. But also, once these files are stored on server, he/she would be able to copy these files from the windows server to another networked computer.
I have found a way to upload files to a specified location on the server disk,
but now I need to send these files that are on server disk to the client computers.
My question is: Is there any way to send or copy files from server to other client computers (not the one that is accessing the web service) without needing a program recieving those files on the client computers? FTP, WCF, cmd commands, sockets?
Any idea?
If you want users of your webapp to download files, I'd look into an "ashx generic handler." It will allow you to send files back down to clients over HTTP(s).
If you are looking to have remote users, tell your webserver to copy files to other servers ON THE SAME LAN AS THE SERVER, you would write using normal System.IO operations.
Over a LAN, if you have the correct permissions and so on, you can write to a disk on a different machine using File.Copy -- there's nothing special about that.
If we're talking about remote machines over the internet, that's a different story. Something has to be listening whether it's FTP, WCF, DropBox, etc.
If the problem is that it can be painful to get something like WCF to work from a client due to problems like firewall issues under Windows 7, you could take a different route and have the client periodically ping the server looking for new content. To give the server a point of reference, the ping could contain the name or creation date of the most recent file received. The server could reply with a list of new files, and then the client could make several WCF calls, one by one, to pull the content down. This pattern keeps all the client traffic outbound.
You can if you can run the program as an account that has access to that computer. However having this sort of access on your network that would grant access to the outside world to put an unfiltered file on your internal network is just asking to be hacked.
Finally, I decided to install a FileZilla FTP server on each client computer and my page is working very well. But another option is to create a work group in the windows server and put every client computer to work in this work group, so that Windows server have access to the computers in the same work group.
Here are some links that may help to create the work groups:
http://helpdeskgeek.com/networking/cannot-see-other-computers-on-network-in-my-network-places/
http://www.computing.net/answers/windows-2003/server-2003-workgroup-setup-/1004.html

Resources