Benutzer:MovGP0/ActiveMQ

aus Wikipedia, der freien Enzyklopädie
   MovGP0        Über mich        Hilfen        Artikel        Weblinks        Literatur        Zitate        Notizen        Programmierung        MSCert        Physik      


ActiveMQ

NMS API

.Net Message Service API (NMS API) provides connectivity to[1]

  • OpenWire
  • Apache ActiveMQ
  • MSMQ
  • TIBCO EMS message broker
  • STOMP
  • WCF

NMS API WCF-Bindings

JMS Message

Default Headers method.[h 1] Description
JMSDeliveryMode
  • Persistent (once and only once)
  • Non-Persistent (at most once)
JMSDestination
  • name of the destination
  • relevant for receivers who subscribed multiple destinations
JMSExpiration
  • DateTime the message expires
JMSMessageID[h 2]
  • string which begins with ID:
  • must be unique
  • might be disabled with MessageProducer.setDisableMessageID()
JMSPriority
  • ranges 0..9
  • 0..4: normal priority
  • 5-9: expedited priority
  • JMS providers may send messages with higher priority first
JMSTimestamp[h 2]
  • DateTime the message was send
  • can be disabled using MessageProvider.setDisableMessageTimestamp()
Optional Headers Description
JMSCorrelationID
  • ID of associated previous message
  • can be a provider-specific message ID starting with ID:, an application-specific string, or byte[].
JMSReplyTo
  • Destination where the reply should be send to
JMSType
  • message type (not data type or class name)
  • not supported by every provider
Optional Provider Headers Description
JMSRedelivered
  • used automatically when message was sent, but not not acknowledged by the receiver
Properties[h 3][h 4] Description
JMSXAppID
  • identifies the application which sends the message
JMSXConsumerTXID
  • transaction identifier
JMSXDeliveryCount
  • number of message delivery attempts
JMSXGroupID
  • id of the message group the message belongs to
JMSXGroupSeq
  • the sequence number of this message within the group
JMSXProducerTXID
  • transaction identifier for the transaction within the message was produced
JMSXRcvTimestamp
  • time the JMS provider delivered the message to the consumer
JMSXState
  • used to define a provider-specific state
JMSXUserID
  • identifies the user sending the message
Payload (Message Body) Types Description
Message
TextMessage
BytesMessage
StreamMessage
ObjectMessage
  1. Default headers are set by the MessageProducer.send()
  2. a b Might be disabled to improve performance on the receiver.
  3. get and set by the various [get|set]TProperty(string name, T value) methods
  4. property names with JMS_<vendor-name> are reserved

NMS API Consumer

using System; 
using Apache.NMS; 
using Apache.NMS.Util; 
using Apache.NMS.ActiveMQ;

namespace MyApp 
{ 
   public class Consumer 
   { 
      public static void Main() 
      { 
         var nmsFactory = new NMSConnectionFactory("tcp://localhost:61616"); 
         IConnection connection = nmsFactory.CreateConnection(); 
         ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge); 
         IDestination destination = session.GetTopic("STOCKS.JAVA"); 
         IMessageConsumer consumer = session.CreateConsumer(destination);
         consumer.Listener += new MessageListener(OnMessage); 
         connection.Start(); 
         
         Console.WriteLine("Press any key to quit."); 
         Console.ReadKey();
      }
      
      protected static void OnMessage(IMessage message) 
      {
         var TextMessage = message as ITextMessage; 
         Console.WriteLine(TextMessage.Text); 
      }
   }
}

Internetquellen

Referenzen

  1. NMS API Overview. In: ActiveMQ. Apache, abgerufen am 11. Juli 2014 (englisch).