Multiple MSMQ communication in WCF - wcf

I am using a client server application in which client send request to server in request queue, server receive this request object from queue process it and send response in response queue which is received by client application. I want same functionality in wcf service and client so whether I need to create two different end points for both msmq and if yes than how same client will work with both endpoints.

You should not think of it as strictly a client server application.
You do have a request originator referred to as client and a request processor referred to as Server,
but when thinking WCF- client is the one sending the message, server is the one receiving. Meaning that in WCf terms, at first your client is really a classic "client" and the server is really a classic "server". But when you get to the point after the original request is processed and needs to be sent back- the roles are reversed! the server becomes a WCf client and the client becomes a WCf server.
What this means is that you processes need to expose a separate endpoint for each other. The server listens on a certain EP for incoming messages (requests), and the client listens on a certain EP for incoming messages (responses).
Hope this clarifies things a bit.

Related

WCF duplex channel for inter-process communication

I have system like this:
Windows service (WCF, data/events) <-> Web app <-> Web client
I need simultaneous response for clients requests. I have some events from service for clients too. So duplex channel is the way to go. But I need high throughput, because clients calls simultaneously.
Request/reply approach
In order not to serialize channel requests I need more channels for parallel calls, right? But how to handle callback channel then? Ho to keep it still open for receiving events, even on channel errors?
OneWay approach
On channel should be enough (no waiting for data preparation), but how to link data sent to callback with original request, to be able to compose response for client?
What is the way to go? Thank you.
In a simple case, when a web client sends a request to the web app, and web app (possibly) sends a request(s) to WCF service, there's no need in duplex binding at all.
As for events, raised by the service to be fired in Web client, I'd suggest to use a message broker which supports WebSockets - for example RabbitMQ. It has a plugin compatible with WebSockets and WCF binding.
Putting things together, one can create a RabbitMQ server, which accepts messages from WCF service and sends it to Web client, which subscribes to the event feed from Javascript.

Can WCF duplex service be used to call client when client is offline?

Is it possible a service to call client after 4 -5 days when client is offline? e.g.
1. The client request some reports through service.
2. Service updates database with client request.
3. Offline work is done on the request
4. Report is uploaded to the database.
Can we service call its client and send report as soon as report is uploaded to database?
Can WCF duplex service be used to call client when client is offline?
Yes. WCF can be configured to use MSMQ as a transport. MSMQ is the only WCF transport that allows for all three:
disconnected scenarios
resume when computer becomes online and
optionally provide a level of guaranteed delivery
MSDN:
If you need to support disconnected queuing, use netMsmqBinding. Queuing is provided by using Microsoft Message Queuing (MSMQ) as a transport, which enables support for disconnected operations, failure isolation, and load leveling. more...
Essentially you invoke a WCF method (send a MSMQ message) and it will be delivered when the computer comes on-line again. Assuming you have set the appropriate expiration options.

Request/response messaging pattern - Azure Service Bus

All ,
I have a doubt on the Request response pattern... Assume the following is my scenario
1.I have a service running on Windows Azure. This service can be called by users to execute a command.
2.I have a client applications that is running on my intranet. This client application will execute the command . The computer in which the client application is running is connected to internet , but does not have a static IP i.e machine cannot be accessed directly via the internet
3.I am planning to use Azure Service Bus through which my service on Windows Azure can communicate with the client application to execute....
In this scenario, can i use Request/response messaging i.e can the service post a message and expect a response from the client
OR
Should i use command queue for each client , the Service will push the command to be executed on a queue , the client will poll the queue and execute a command
Any help is appreciated
Since you are using WCF (based on the tag), you should consider using Service Bus Relay calling the WCF service asynchronously.
I assume you want to use Relaybinding here, using WCF.
Your web service (which is behind NAT, firewall devices, etc) is only opening outbound connections in that case. The service is listening on a registered endpoint in the cloud (that is accessible for him, because of credentials and protocol). All incoming service calls are sent over that port/socket. The response will then be sent back over the outgoing port again.
If the IP Address of your service changes, it wil register itself again (by listening on the same registered endpoint) and you can reach that service transparantly.
Another way you can achieve request/response in an asynchronous fashion, is through queues. This does not require any open connection between your client and your service and can happen fully asynchronous. This can be achieved by sending a message to the request queue for your specific service (with a Correlation Id). And when that service has processed that message, it can send the response to the response queue of your application, using sessions. A good example of this pattern can be found on Alan Smith's blog: http://www.cloudcasts.net/devguide/Default.aspx?id=13051

WCF client service communication

I have a very basic question about wcf service with basicHttpbinding:
When client calls a wcf service(basichttpbinding) synchronously how the request and response is received between two? Does a socket connection established between 2 and port on server tied up till response is received on client? How the response is sent back to the waiting client? IF port on server is unusable for long running operation then will it hinder service ability to accept request from other client? Also, how communication happens in can of asynchronous call to wcf service? I read that channel and hence port/socket should remain open at both ends.
With basichttpbinding, it's much the same as normal http communication between a browser and a web server. If you hit a link on a web page, a request from the browser is sent to the appropriate web server, which processes the request and returns the content, as a response, to the waiting browser.
It's the same with WCF basicHTTPBinding. The WCF client sends a post or get request to the designated web service (http: //webservice:port/ServiceObj/MethodName) and waits for a response. When the web service finishes gathering the data, the data is sent back to the client in the response on the open connection, which is then closed by the host. There's no persistant connection. Thus, basichttpbinding is stateless. Once the web service sends the response, connection is recycled and the service is ready to go for the next request.
If the client is finished with its communication, it can close its connection explicitly; that's best. But if it doesn't close its connection, it won't make any difference to the host.

WCF service to queue all request

I have a wcf service and handle a lot of client (server document generation). This service should receive a lot of request and should be handle in queue. It also have a callback. (callback will return successfully generated document). I am still using PIA and will implement OpenXML in the future.
Is it wcf msmq is the way to implement this?
Is there any samples might be related? Previously its running in local machine but now want to change it as a so called "Server generated"
WCF MSMQ doesn't support callback directly - it supports only one-way operations. But for example this article discuss how to add this support. With default configuration you can send message back to original sender but it is not a callback. To support responses every client will have to expose queue and pass address of its queue as part of the request to be able to receive the message from the service. More about responses in MSMQ is in MSDN magazine.