Neuron ESB User Network

The Service Bus for the Connected Business

Best way to stop Windows Service listening messages on ESB?

We have a Windows Service that has a Subscriber listening for messages from RabbitMQ. (It also publishes messages). When we stop the service, we want to stop processing new messages and allow all currently processing message threads to continue and finish processing (up to some timeout).

We tried this pattern:

OnStop()

{

   Log("Pausing");

   Subscriber.Pause();

   // Wait for any messages to finish processing.

   // Another option is to have a counter somehow keep track of the number of currently processing messages and wait for it to go to zero

   Log("Waiting");

   Thread.Sleep(10 * 1000); 

   Log("Disposing");

   Subscriber.Dispose();

}

This seems to work, except we see this error in our log:

Pausing

NeuronEventLog Disconnecting party. Party DialIqServiceSubscriber, session 09ebb527-b27b-4e2d-bae7-d07302467826, server address net.tcp://localhost:50013/ESBTcpPubSub/, client address net.tcp://pc000185.office.leads360.com:61014/ESBTcpPubSubClient/09ebb527-b27b-4e2d-bae7-d07302467826, topic Infrastructure

ERROR NeuronEventLog Consume Messages: There was an error reported for the RabbitMQ channel for topic "DialerQueue": Thread was being aborted.

Inner Exception: Thread was being aborted.
Neuron.Esb.Channels.Amqp.AmqpChannelException: Consume Messages: There was an error reported for the RabbitMQ channel for topic "DialerQueue": Thread was being aborted. ---> System.Threading.ThreadAbortException: Thread was being aborted.
at Neuron.Esb.Channels.Amqp.AmqpChannel.ConsumeMessages()
--- End of inner exception stack trace ---

Waiting

Disposing

No matter what we try and what timing we use, we always get a thread was being aborted exception and in some cases we never finish processing our message handler threads.

Should we be using a different/better method?

We are using version 3.1.

Thanks in advance,

Dan

Views: 617

Reply to This

Replies to This Discussion

when you refer to "stop processing new messages and allow all currently processing message threads to continue and finish processing", are you referring the threads within the windows service, or processing you're doing within the OnReceive event? 

if you throw an error within the onreceive event, the message will be rolled back to the underlying rabbit MQ queue.  I believe Pause does the disconnect.  but throwing the threadAbortException is a bug that we can fix.  Please send a support request to NeuronSupport@neudesic.com.  This will open a ticket and we can fix.

Thanks

Hi Marty, 

Thanks for replying (I just also sent an email to your support regarding this question).

What we want is to be able to cleanly shut down the Windows Service instance (for example when we want to deploy a new version). In order to do this, we want to be able to stop receiving new messages on this service instance. But we don't want to abort any OnReceive threads that are currently executing (unless they take too long).

Dan

RSS

Neuron ESB Product Support Forums and Communities

Latest Activity

Anupama Nair posted a discussion

Marketo Adapter Invalid Token

Hi,We are using the Marketo adapter to push account updates to Marketo. It works well for some time then starts failing with Invalid Token unless restarted. Is there a configuration that can be done so it can auto refresh the token when required?Thanks!See More
Nov 6, 2023
Sayantini Basak posted a discussion

Maximum payload size(REST API) for requests interfacing to NeuronESB

I am new to Neuron ESB and in our current scenario,We need to process batch transactions comprising of ~1000 records and send them to Neuron ESB for further processing. I would like to understand what is the maximum size of payload that can be transferred using REST interface to Neuron ESB.See More
Jul 22, 2022
Profile IconRobert E Dunie and Sayantini Basak joined Neuron ESB User Network
Apr 28, 2022
Profile IconDayanand, Frederic C, Steffen Greve-Oksfeldt and 1 more joined Neuron ESB User Network
Mar 16, 2022
Profile IconCam Vong and Mitja Luznar joined Neuron ESB User Network
Jan 27, 2022
Profile IconWill Hitzges, Chad Parsons, michael larsen and 4 more joined Neuron ESB User Network
Jun 11, 2021
Anupama Nair posted a discussion

ODBC stored proc polling with temporary tables

We have set up an ODBC adapter to poll a stored proc.We found that if the stored proc has a temporary table defined the rows returned are always 0.Any idea why this would be and what we can do to get around it?See More
Dec 14, 2020
Prasanth Kharade is now a member of Neuron ESB User Network
Dec 30, 2019

Badge

Loading…

© 2024   Created by Neuron Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service