Ejemplo n.º 1
0
        public Apache.NMS.IMessageProducer CreateProducer(Queue queue)
        {
            if (this.queueConnection.IsStarted)
            {
                throw new QueueingException("Cannot create producer on an already opened connection. Create new session instead.");
            }

            this.OpenConnection(this.queueConnection, queue);
            Apache.NMS.IDestination     destination = SessionUtil.GetDestination(this.queueSession, queue.Name);
            Apache.NMS.IMessageProducer producer    = this.queueSession.CreateProducer(destination);
            producer.TimeToLive = queue.MessageTimeToLive;

            return(producer);
        }
Ejemplo n.º 2
0
        public Apache.NMS.IMessageProducer CreateProducer(
            Apache.NMS.IDestination destination)
        {
            Apache.NMS.XMS.Destination destinationObj =
                (Apache.NMS.XMS.Destination)destination;

            try
            {
                Apache.NMS.IMessageProducer producer =
                    XMSConvert.ToNMSMessageProducer(this,
                                                    this.xmsSession.CreateProducer(
                                                        destinationObj.xmsDestination));
                ConfigureProducer(producer);
                return(producer);
            }
            catch (Exception ex)
            {
                ExceptionUtil.WrapAndThrowNMSException(ex);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public void OnMessage(IMessage nmsMessage, ISession session)
        {
            object obj = messageConverter.FromMessage(nmsMessage);

            Spring.Integration.Core.IMessage requestMessage = obj as Spring.Integration.Core.IMessage;
            if (requestMessage == null)
            {
                requestMessage = MessageBuilder.WithPayload(obj).Build();
            }
            if (!expectReply)
            {
                bool sent = channelTemplate.Send(requestMessage);
                if (!sent)
                {
                    throw new MessageDeliveryException(requestMessage, "failed to send Message to request channel");
                }
            }
            else
            {
                Spring.Integration.Core.IMessage replyMessage = channelTemplate.SendAndReceive(requestMessage);
                if (replyMessage != null)
                {
                    IDestination        destination = GetReplyDestination(nmsMessage, session);
                    Apache.NMS.IMessage nmsReply    = messageConverter.ToMessage(replyMessage, session);
                    if (nmsReply.NMSCorrelationID != null)
                    {
                        nmsReply.NMSCorrelationID = nmsMessage.NMSMessageId;
                    }
                    Apache.NMS.IMessageProducer producer = session.CreateProducer(destination);
                    try
                    {
                        producer.Send(nmsReply);
                    } finally
                    {
                        producer.Close();
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void ConfigureProducer(Apache.NMS.IMessageProducer producer)
 {
     producer.ProducerTransformer = this.ProducerTransformer;
 }