How does RabbitMQ WCF tolerate service failures? - c#

Suppose I have a WCF service that I bind/expose using the RabbitMQ WCF interface/binding. If I have clients that make calls to my service through the RabbitMQ WCF interface then what would happen if let's say the service goes down?
Would RabbitMQ just store the requests to that service and once the service comes up it will pass those requests to the service?
Would the client get a "service not found" message or some sort of "service is disconnected" message?
How is WCF connectivity implemented within RabbitMQ? Does RabbitMQ keep a queue where the WCF service requests go and if the service goes down then the queue just keeps growing until the service comes back online?

Through some experimenting with the WCF API it doesn't appear like the client and the server are tightly coupled. I tried to bring up multiple instances of the client without the server coming up and there was no error. When I brought up the server it saw the message from the clients and responded to each client. So it looks like the client publishes a message onto the queue and when the server piece wakes up it takes the message from the queue.

Related

Can a WCF service use SignalR to notify clients of a change?

I have a mature client/service project that uses WCF services for the data access. These are called from a WPF client.
We now want to add notifications to the project, so have been looking at SignalR to push those notifications to the clients. This all works fine when it's SignalR itself that's initiating the push, say a client sends a SignalR notification to the server, the server can then notify all other clients.
However, as all of our data access is done via the WCF services, I want to be able to send out a SignalR notification in response to a WCF service call. For example, a client calls the UpdateCustomer() service call, which saves the modified customer data to the database. I then want to notify all other clients of the change. However, at this stage I'm in the WCF service code, not the SignalR code.
How do I tell SignalR to send out a notification?
Ah, found it just after posting!
Predictably, it was in the SignalR docs, How to call client methods and manage groups from outside the Hub class.

WCF IBM Websphere MQ Communication (WCF Listener)

I have a wcf service that executes some code and sends a message to the IBM WebSphere MQ hosted on a linux server. I can put and get messages from the queue just fine. What I wanted to know that is there a way by which whenever a message is sent to the queue a listener service (WCF) activates to process those messages? (this can be done by using netmsmqbinding and WAS for MSMQ)
I have researched a lot but was unable to find any code examples which made me think that is this even possible....
I have looked at some answers but they don't link wcf and mq part. A similar question is WCF / WebService to act as Listener for MQ Message? but there is no concrete answer. I have also looked at Listening to new enqueued messages using WCF Service.
So this scenario lead me to think that my only option is to write a windows service that after some interval listens (polls i.e invokes the get method on) the queue or write a console application that does that same thing.
Does anyone have a more elegant solution?
Triggering might be an option. WebSphere MQ can start an application when a message arrives on a queue:
http://www-01.ibm.com/support/docview.wss?uid=swg27020075&aid=1
As you want to trigger an application not running on the server of the queue manager, you will need a trigger monitor like this:
http://www-01.ibm.com/support/docview.wss?uid=swg24000149

Call a method from SOAP Web Service

I'm working on a protocol which is designed to be implemented with SOAP over HTTP.
WSDL files are provided by a third party.
I used wsdl.exe to generated a proxy class and created a Web Service Project in VS.
wsdl.exe yourFile.wsdl /l:CS
I got a cs from a unwrapping wsdl.
Snippet:
[System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("/ClearCache", RequestElementName="clearCacheRequest", RequestNamespace="urn://Ocpp/Cp/2012/02/", ResponseElementName="clearCacheResponse", ResponseNamespace="urn://Ocpp/Cp/2012/02/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("status")]
public abstract ClearCacheStatus ClearCache();
Implementation 1 (Server Side)
A central system (Server) connected to devices. When a device initialized, it sends an authorisation to central system.
And Server response an authorisation message back.
I have already done with Server Side which provides all clients send requests to Server. And Server response the messages.It works well.
Implementation 2 (Central system send a message to a device)
The other part of implementation is a central system need to send message to device (ex. clear devices cache, please see a snippet above). I add those methods to web service as well.
My questions are...
How can I send a message to devices through a proxy from Web Service?
It's impossible to call a method from Web Service sending requests to device? Any suggestions?
Or I need to create a project implementing a ClearCache method and format as a SOAP message to trigger?
Thanks!
I dont think it is a good idea to allow the Central system to directly communicate with the clients (Will create a huge noise in the network if the number of devices is high and the server tries to send several messages)..
A better approach will be to allow all the messages that the server intends to send to the client to be cached locally in the server machine. The clients should periodically communicate with the server using another web service and obtain the cached information that you intend to send to the clients.
you can design a method that sends the guid of the client as a parameter in the web service call.
On the server you maintain a database and keep track of the messages that needs to be sent to the clients.
use a timer object in the clients. On elapse of the timer define a method that communicates with the server by sending its guid. On the server side use this guid as a Primary Key to identify wat messages need to be sent to the client and then reply that while returning from the message.
The client then uses this return value to decide how to respond.

WCF have multiple connections open

I am creating a WCF service where multiple users connect to it. On my WCF I implement callback contracts so that if a user makes a specific action it can notify other computers that are connected to the same WCF service. So if Company A creates an action on the WCF service then the WCF service will make a callback to all Company A machines that are connected to it. Company B will receive no notifications for example.
Anyways so far everything works great NOW. what about in the future where there are more connections at the same time? will that cause a problem?
To avoid that problem will it be better to create a web service where connections are not held open? The problem with this approach is the callback mechanism where the web service needs to send a notification to multiple computers In order to resolve the callback problem I am going to have all machines sending a UDP packet every 10 seconds to the web server. (this will make the router open a port so that the web server can reply in case it needs to) If the web service needs to send a notification to all computers on Company A for instance then it will Send multiple UDP packets. If a computer receives a UDP packet from the web service then it knows it has to make a request to perform the callback. Should I use this approach?

WCF or windows service to implement MSMQ

I have a client server setup where i am sending the messages to the server over http(I am using WCF service hosted as windows service.)In my current setup as I have seen some messages are lost when the connection is down between client and server ,for the sake of reliability i have decided to use MSMQ.So the client sends the messages to the queue and the server continuously polls the queue I need some design decision to be taken before i will developing.
Which one would be the best bet windows service or wcf service(hosted as windows service) ?
Are there any advantages apart from windows service which WCF has if i have to develop such a service where all it has to do is continuusly read messages from the queue and does some processing.I would be using a private queue which is transnactional .
I would suggest avoiding writing code that directly integrates with MSMQ and instead using an existing service bus to do that for you (like NServiceBus or MassTransit). Rolling-your-own messaging layer may work for the simplest of systems but as requirements change over time you will need a fuller featured service bus. The service buses that I mentioned do the following things in a developer friendly way:
Messaging patterns (fire-and-forget, request-response, publish subscribe)
Message serialization
Message routing
Failure/Retry logic (i.e. a message handler is supposed to update a database, but the database is down how do you handle this?)
Long running processes (also called sagas)
These are just a few of the things you will be writing before long if you go the roll-your-own route.

Categories

Resources