-1

I have a problem in activemq. I want to receive a special message from my activemq queue. I have there over 300 Messages, and I want one of the message. I solved this with a multiselectcombobox. In this box I have all messages with all properties I need.

When I click on the 247 item, I want do select the item to receive the message, after them I want to send the message but first I have a problem with the receive.

I don't know why it doesn't work. Maybe someone has an idea?

ErrorMessageProperty prop = new ErrorMessageProperty();
IMessage message = null;

try
{
    string MsgID = MSGID;
    string desinationque = sourceQueue;
    string selector = "ProducerId = '" + MsgID + "'";
    IDestination dest = MQSession.GetDestination(desinationque);
    Uri _activeMQURI = new Uri(conf.ActiveMqURL);
    MQConnectionFactory = new NMSConnectionFactory(_activeMQURI);

    using (MQConnection = MQConnectionFactory.CreateConnection(conf.ActiveMqUser, conf.ActiveMqPWD))
    using (MQSession = MQConnection.CreateSession(AcknowledgementMode.AutoAcknowledge))
    {
        try
        {
            MQConnection.Start();
        }
        catch (Exception ex)
        {
            myLogger.NLogger.Info("MQReceiveTextMessage Connection fehlgeschlagen: " + ex.Message);
        }

        using (IMessageConsumer consumer = this.MQSession.CreateConsumer(dest, selector,false))
        {
            if (shallwait)
            {
                try
                {
                    message = consumer.Receive();
                }
                catch (Exception ex)
                {
                    myLogger.NLogger.Error("Error in consumer Receive (MQReceiveTextMessage): Message" + message + " Fehler-Exception: " + ex.Message);
                }
            }
            else
            {
                message = consumer.Receive(TimeSpan.FromSeconds(1));
            }
        }
    }
}
catch (Exception ex)
{
    myLogger.NLogger.Error("Error in MQReceiveTextMessage: Parameter: sourceQueue: " + sourceQueue + " MSGID: " + MSGID + " Message: " + message + " Fehler-Exception: " + ex.Message);
}

return message;
}

My ProducerID is correct. But why doesn't this work? It stops at the line

message = consumer.receive();

I don't know anymore

2 Answers2

0

With the selector ProducerId = 'MsgIDValue', the operation consumer.receive() is searching a Message in the queue with a custom property "ProducerId" with the value of the variable MsgID. If the message is not found the consumer waits new messages.

If you want to search for a default message field, message header field references are restricted to JMSDeliveryMode, JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be null and if so are treated as a NULL value.

Source Message Selectors

Óscar M.
  • 1
  • 2
0

I used Apache.NMS and Apache.NMS.ActiveMQ (1.7.1.3924) is it possible to u se this api than the jms? I try this since 1 Week and the selector does'nt work.... Maybe someone othe