예제 #1
0
        public static IDestination CreateDestinationFromMessage(Connection source, Properties properties, byte type, bool replyTo = false)
        {
            IDestination dest = null;

            if (properties == null || source == null)
            {
                return(dest);
            }
            bool isPropertyNull = (!replyTo) ? properties.To != null : properties.ReplyTo != null;

            if (isPropertyNull)
            {
                string destname = (!replyTo) ? properties.To : properties.ReplyTo;
                destname = UriUtil.GetDestinationName(destname, source);
                switch (type)
                {
                case JMS_DEST_TYPE_TEMP_QUEUE:
                    dest = new TemporaryQueue(source, destname);
                    break;

                case JMS_DEST_TYPE_QUEUE:
                    dest = new Queue(source, destname);
                    break;

                case JMS_DEST_TYPE_TEMP_TOPIC:
                    dest = new TemporaryTopic(source, destname);
                    break;

                case JMS_DEST_TYPE_TOPIC:
                    dest = new Topic(source, destname);
                    break;
                }
            }
            return(dest);
        }
예제 #2
0
        public RequestHandle SendRequest(string destination, BinaryMessage message, Action <BinaryMessage> callback)
        {
            ensureSessionIsCreated();
            TemporaryQueue temporaryQueue = m_Session.createTemporaryQueue();
            var            request        = new RequestHandle(callback, temporaryQueue.delete,
                                                              cb => subscribe(temporaryQueue, m => cb(toBinaryMessage(m)), null));

            m_Subscriptions.Add(request);
            send(destination, message, SonicTransportConstants.MESSAGE_DEFAULT_LIFESPAN,
                 m => m.setJMSReplyTo(temporaryQueue));
            return(request);
        }
예제 #3
0
 public object ConvertAndSendRequestReply(object objectToSend)
 {
     return(Execute(delegate(ISession session, IMessageProducer producer)
     {
         TemporaryQueue tempQueue = null;
         try
         {
             tempQueue = session.CreateTemporaryQueue();
             this.ConvertAndSendWithDelegate(objectToSend, delegate(Message message)
             {
                 message.ReplyTo = tempQueue;
                 return message;
             });
             return ReceiveAndConvert(tempQueue);
         }
         finally
         {
             //TODO use Admin API
             //if (tempQueue != null) session.DeleteDestination(tempQueue);
         }
     }));
 }