3

I have a synchronous message transaction within my system, and the process broadly follows this flow:

  1. "Point A" creates a temporary queue ("destination 2") on the message broker;
  2. Message sent from point A to destination 1 (a normal queue on the message broker), with the ReplyTo address set as destination 2;
  3. point A blocks waiting for response on destination 2;
  4. point B receives message from destination 1;
  5. point B creates a work object - a property of which is the name of destination 2 (derived using .ToString()". This work object is serialized and stored in the DB;

...

  1. Object retrieved from DB when certain parameters are met, changes ocurr, and a response is sent to destination 2 - using SessionUtil to derive a new IDestination object from the replyto address stored as a string property of the work object;
  2. "Point A" recieves message from destination 2 and continues on.

This process can take anything from a split second to several seconds to accomplish.

I need to use the name of the return destination (destination 2), rather than the full IDestination object, as I have to serialize the object and store in the DB.

If I use a permanent queue or a topic as destination 2, the process works fine. However, it always fails when attempting to create it using the string name of the temporary queue.

There are no errors, the message just fails to arrive

Any ideas why?

Example code for sending return message shown:

IDestination myDestination = SessionUtil.GetDestination(stateSession, instance.ReplyTo, DestinationType.Queue);

stateConnection.Start();

using (IMessageProducer myProducer = stateSession.CreateProducer(myDestination))
{
myProducer.DeliveryMode = MsgDeliveryMode.NonPersistent;
var response = myProducer.CreateTextMessage();

response.NMSCorrelationID = instance.CorrelationID;
response.Properties["RoutingDestination"] = instance.RoutingOriginator;
response.Text = "Test Response";

try
{
    myProducerBroadcast.Send(response);
    myProducer.Send(response);

    Log.InfoFormat("Sent response {0} to {1}", instance.UniqueId, instance.ReplyTo);
}
catch (Exception ex)
{
    Log.Error("Unable to send execution update onwards", ex);
}                
}

("instance" is the work object - which contains the ReplyTo address and other information)

rvxnet
  • 457
  • 5
  • 16
  • instance.ReplyTo in this example is set to "temp-queue://ID:HL003323-52604-634308828390407226-1:1:1" – rvxnet Jan 18 '11 at 09:02

2 Answers2

4

A temporary destination is just that, temporary. Once the Connection object that created the Temporary Destination closes, the destination is automatically removed from the broker. Storing the temp destination for later use is not a good idea for this reason. Also, only the Connection that created the temp destination is allowed to consume on it.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • Many thanks for your response Tim. I do see what you're saying, but I'm looking at spans of a few seconds, and during this period the caller would be holding open the temporary queue waiting for the response. If the destination no longer exists I would expect to see (and do see) an exception being raised. However, when sending to a temporary queue (even if it still exists), using this string reference as the source, it does not seem to send and no exception is raised. – rvxnet Jan 19 '11 at 14:50
  • Well, without a test case its hard for me to say. Creating a Temp Queue is really meant to be done via Session.CreateTemporaryQueue, not by using a string value obtained from ToString, so its not surprising to me that it doesn't work. If you can create a test case and open a new Jira issue I can look into it and determine if its valid or possible. – Tim Bish Jan 19 '11 at 16:03
0

I did notice temp queues don't work if the broker is configured to not use "advisorySupport"

Reenabling that got the queues to work for me.

Richard
  • 302
  • 2
  • 9