Benutzer:MovGP0/ActiveMQ

  MovGP0    Über mich    Hilfen    Artikel    Weblinks    Literatur    Zitate    Notizen    Programmierung    MSCert    Physik   


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 HeadersDescription
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 HeadersDescription
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) TypesDescription
Message
TextMessage
BytesMessage
StreamMessage
ObjectMessage

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