Search in sources :

Example 11 with JMSException

use of javax.jms.JMSException in project ACS by ACS-Community.

the class DefaultPublisherImpl method createTextMessage.

/**
   * Method createTextMessage
   *
   *
   * @return TextMessage
   *
   * @throws JMSException
   *
   */
public TextMessage createTextMessage() throws JMSException {
    if (closed) {
        throw (new JMSException("Publisher object has been closed"));
    }
    TextMessage message = null;
    message = session.createTextMessage();
    return message;
}
Also used : JMSException(javax.jms.JMSException) TextMessage(javax.jms.TextMessage)

Example 12 with JMSException

use of javax.jms.JMSException in project ACS by ACS-Community.

the class DefaultPublisherImpl method initialize.

/**
   * Method initialize.
   *
   * @param retry
   * @throws MOMException
   */
private void initialize(boolean retry) throws MOMException {
    momProperties = MomConfig.getProperties(this.getClass().getClassLoader());
    defaultPersistance = (momProperties.getProperty(MomConfig.MSG_PERSISTANCE_PROPERTY).equals("true") ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
    defaultPriority = Integer.parseInt(momProperties.getProperty(MomConfig.MSG_PRIORITY_PROPERTY));
    defaultTimeToLive = Long.parseLong(momProperties.getProperty(MomConfig.MSG_TIMETOLIVE_PROPERTY));
    topicDirectory = new HashMap();
    try {
        connection = JMSTopicConnectionFactory.createJMSTopicConnection(username, password, brokerList, loadBalancing, sequential, selectorAtBroker);
        connection.connect(retry);
        connection.setExceptionListener(this);
        session = connection.createTopicSession();
        connection.start();
        publisher = session.createPublisher(null);
        closed = false;
    } catch (ConnectionException e) {
        System.out.println("Exception caught: " + e.getMessage());
        e.printStackTrace(System.err);
        throw new MOMException("Unable to estabilish a connection, cause is : " + e.getMessage());
    } catch (JMSException e) {
        System.out.println("Exception caught: " + e.getMessage());
        e.printStackTrace(System.err);
        throw (new MOMException(e.getMessage()));
    }
}
Also used : HashMap(java.util.HashMap) JMSException(javax.jms.JMSException) MOMException(cern.cmw.mom.pubsub.MOMException)

Example 13 with JMSException

use of javax.jms.JMSException in project ACS by ACS-Community.

the class DefaultPublisherImpl method createBytesMessage.

/**
   * Method createBytesMessage
   *
   *
   * @return BytesMessage
   *
   * @throws JMSException
   *
   */
public BytesMessage createBytesMessage() throws JMSException {
    if (closed) {
        throw (new JMSException("Publisher object has been closed"));
    }
    BytesMessage message = null;
    message = session.createBytesMessage();
    return message;
}
Also used : JMSException(javax.jms.JMSException) BytesMessage(javax.jms.BytesMessage)

Example 14 with JMSException

use of javax.jms.JMSException in project ACS by ACS-Community.

the class DefaultPublisherImpl method createStreamMessage.

/**
   * Method createStreamMessage
   *
   *
   * @return StreamMessage
   *
   * @throws JMSException
   *
   */
public StreamMessage createStreamMessage() throws JMSException {
    if (closed) {
        throw (new JMSException("Publisher object has been closed"));
    }
    StreamMessage message = null;
    message = session.createStreamMessage();
    return message;
}
Also used : JMSException(javax.jms.JMSException) StreamMessage(javax.jms.StreamMessage)

Example 15 with JMSException

use of javax.jms.JMSException in project ACS by ACS-Community.

the class DefaultSubscriberImpl method unSubscribe.

/**
   * Method unSubscribe
   *
   *
   * @param token
   *
   * @throws JMSException
   *
   */
public void unSubscribe(long token) throws JMSException {
    cat.info("unSubscribe(" + token + ")");
    if (closed) {
        throw (new JMSException("Subscriber closed."));
    }
    synchronized (subscribers) {
        Long key = new Long(token);
        SubscriptionHandle handle = (SubscriptionHandle) subscribers.get(key);
        if (handle != null) {
            handle.getSubscriber().close();
            handle.getSession().close();
            if (!NotificationHelper.isNotification(handle.getSubscriptionTopic())) {
                publishNotification(NotificationHelper.CONSUMER_CLOSE_NOTIFICATION, handle);
            }
            subscribers.remove(key);
        }
    }
}
Also used : JMSException(javax.jms.JMSException)

Aggregations

JMSException (javax.jms.JMSException)1038 Message (javax.jms.Message)335 Test (org.junit.Test)320 Session (javax.jms.Session)297 TextMessage (javax.jms.TextMessage)288 Connection (javax.jms.Connection)253 MessageProducer (javax.jms.MessageProducer)160 MessageConsumer (javax.jms.MessageConsumer)148 Destination (javax.jms.Destination)99 ObjectMessage (javax.jms.ObjectMessage)98 Queue (javax.jms.Queue)93 MapMessage (javax.jms.MapMessage)66 ConnectionFactory (javax.jms.ConnectionFactory)63 CountDownLatch (java.util.concurrent.CountDownLatch)61 IOException (java.io.IOException)59 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)53 BytesMessage (javax.jms.BytesMessage)52 MessageListener (javax.jms.MessageListener)50 MessageFormatException (javax.jms.MessageFormatException)43 HashMap (java.util.HashMap)40