ionic.Msmq
Class Queue

java.lang.Object
  extended by ionic.Msmq.Queue

public class Queue
extends java.lang.Object

The Queue class represents a message queue in MSMQ.

Applications can instantiate a Queue, then perform send and receive operations on the queue, using instances of the Message type.

Queue also exposes several static methods for Queue management, to support creation and deletion of message queues.


Nested Class Summary
static class Queue.Access
           The Queue.Access enum provides options for access to the MSMQ Queue: Either Receive, Send, or both.
 
Constructor Summary
Queue(java.lang.String queueName)
          Call this constructor to open a queue by name for SEND and RECEIVE operations.
Queue(java.lang.String queueName, Queue.Access access)
          Call this constructor to open a queue with the specified access
 
Method Summary
 void close()
          Close the queue.
static Queue create(java.lang.String queuePath, java.lang.String queueLabel, boolean isTransactional)
           Create a queue by name, with the given queue label and transactional access.
static void delete(java.lang.String queuePath)
          Delete a queue by the given name.
 java.lang.String getFormatName()
          Gets the formatname on the queue.
 java.lang.String getLabel()
          Gets the label on the queue.
 java.lang.String getName()
          Gets the name of the queue.
 boolean isTransactional()
          Gets the transactional setting for the queue.
 Message peek()
          Peek at the queue and return a message without dequeueing it.
 Message peek(int timeout)
          Peek at the queue and return a message without dequeueing it,
 Message receive()
          Poll the queue to receive one message, with an infinite timeout.
 Message receive(int timeout)
          Poll the queue to receive one message, with the given timeout.
 void send(byte[] b)
          Send a byte array as a Message.
 void send(Message msg)
          Send a Message on the queue.
 void send(Message msg, boolean highPriority)
          Send a Message, with the given value for high priority.
 void send(Message msg, boolean highPriority, TransactionType t)
          Send a Message, with the given transaction type, and with the given setting for high priority.
 void send(Message msg, TransactionType t)
          Send a Message, with the given transaction type.
 void send(java.lang.String s)
          Send a string as a Message, using UTF-8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue(java.lang.String queueName)
      throws MessageQueueException

Call this constructor to open a queue by name for SEND and RECEIVE operations.

Here's an example of how to use it, to send a simple message:

   Queue queue= new Queue(fullname);
   String body = "Hello, World!";
   String label = "Greeting";
   String correlationId= "L:none";
   Message msg= new Message(body, label, correlationId);
   queue.send(msg);
 

Throws:
MessageQueueException

Queue

public Queue(java.lang.String queueName,
             Queue.Access access)
      throws MessageQueueException
Call this constructor to open a queue with the specified access

Throws:
MessageQueueException
Method Detail

create

public static Queue create(java.lang.String queuePath,
                           java.lang.String queueLabel,
                           boolean isTransactional)
                    throws MessageQueueException

Create a queue by name, with the given queue label and transactional access.

Example:

   String fullname= ".\\private$\\" + qname;
   String qLabel="Created by " + this.getClass().getName() + ".java";
   boolean transactional= false;  // should the queue be transactional
   queue= Queue.create(fullname, qLabel, transactional);
 

Throws:
MessageQueueException

delete

public static void delete(java.lang.String queuePath)
                   throws MessageQueueException
Delete a queue by the given name.

Throws:
MessageQueueException

send

public void send(Message msg,
                 boolean highPriority,
                 TransactionType t)
          throws MessageQueueException
Send a Message, with the given transaction type, and with the given setting for high priority.

Throws:
MessageQueueException

send

public void send(Message msg,
                 TransactionType t)
          throws MessageQueueException
Send a Message, with the given transaction type.

Throws:
MessageQueueException

send

public void send(Message msg,
                 boolean highPriority)
          throws MessageQueueException
Send a Message, with the given value for high priority.

Throws:
MessageQueueException

send

public void send(Message msg)
          throws MessageQueueException
Send a Message on the queue.

Throws:
MessageQueueException

send

public void send(java.lang.String s)
          throws MessageQueueException,
                 java.io.UnsupportedEncodingException
Send a string as a Message, using UTF-8 encoding. The label used will be blank, and the correlationId will be null (none).

Throws:
MessageQueueException
java.io.UnsupportedEncodingException

send

public void send(byte[] b)
          throws MessageQueueException
Send a byte array as a Message. The label used will be blank, and the correlationId will be null (none).

Throws:
MessageQueueException

receive

public Message receive(int timeout)
                throws MessageQueueException
Poll the queue to receive one message, with the given timeout.

If the timeout expires before a message becomes available, the method will throw an exception.

Throws:
MessageQueueException

receive

public Message receive()
                throws MessageQueueException
Poll the queue to receive one message, with an infinite timeout.

Throws:
MessageQueueException

peek

public Message peek()
             throws MessageQueueException
Peek at the queue and return a message without dequeueing it.

Throws:
MessageQueueException

peek

public Message peek(int timeout)
             throws MessageQueueException
Peek at the queue and return a message without dequeueing it,

If the timeout expires before a message becomes available, the method will throw an exception.

Throws:
MessageQueueException

close

public void close()
           throws MessageQueueException
Close the queue.

Throws:
MessageQueueException

getName

public java.lang.String getName()
Gets the name of the queue.

Returns:
the name of the queue.

getLabel

public java.lang.String getLabel()
Gets the label on the queue.

Returns:
the label on the queue.

getFormatName

public java.lang.String getFormatName()
Gets the formatname on the queue.

Returns:
the formatname of the queue.

isTransactional

public boolean isTransactional()
Gets the transactional setting for the queue.

Returns:
the transactional setting for the queue.