Search in sources :

Example 1 with Destination

use of com.sun.messaging.jmq.jmsservice.Destination in project openmq by eclipse-ee4j.

the class StompTransactedSession method createSubscriber.

public StompSubscriber createSubscriber(String subid, StompDestination d, String selector, String duraname, boolean nolocal, StompOutputHandler out) throws Exception {
    checkSession();
    synchronized (this) {
        if (subscribers.get(subid) != null) {
            throw new StompProtocolException("Subscriber " + subid + " already exist in transacted session " + this);
        }
        String stompdest = stompconn.getProtocolHandler().toStompFrameDestination(d, false);
        Destination dest = ((StompDestinationImpl) d).getDestination();
        JMSServiceReply reply = null;
        try {
            reply = jmsservice.createDestination(connectionId, dest);
        } catch (JMSServiceException jmsse) {
            JMSServiceReply.Status status = jmsse.getJMSServiceReply().getStatus();
            if (status == JMSServiceReply.Status.CONFLICT) {
                if (getDEBUG()) {
                    logger.log(logger.INFO, "Destination " + stompdest + " already exist");
                }
            } else {
                throw jmsse;
            }
        }
        reply = jmsservice.startConnection(connectionId);
        reply = jmsservice.addConsumer(connectionId, sessionId, dest, selector, duraname, (duraname != null), false, false, stompconn.getClientID(), nolocal);
        long consumerId = reply.getJMQConsumerID();
        TransactedSubscriber sub = new TransactedSubscriber(subid, consumerId, duraname, stompdest, out);
        subscribers.put(subid, sub);
        return sub;
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsservice.Destination) StompDestination(com.sun.messaging.bridge.api.StompDestination) JMSServiceReply(com.sun.messaging.jmq.jmsservice.JMSServiceReply) JMSServiceException(com.sun.messaging.jmq.jmsservice.JMSServiceException) StompProtocolException(com.sun.messaging.bridge.api.StompProtocolException)

Example 2 with Destination

use of com.sun.messaging.jmq.jmsservice.Destination in project openmq by eclipse-ee4j.

the class StompSessionImpl method createTempStompDestination.

@Override
public StompDestination createTempStompDestination(boolean isQueue) throws Exception {
    String name = null;
    if (isQueue) {
        name = ClientConstants.TEMPORARY_DESTINATION_URI_PREFIX + ClientConstants.TEMPORARY_QUEUE_URI_NAME + stompconn.getIdForTemporaryDestination();
        return new StompDestinationImpl(new Destination(name, com.sun.messaging.jmq.jmsservice.Destination.Type.QUEUE, com.sun.messaging.jmq.jmsservice.Destination.Life.TEMPORARY));
    }
    name = ClientConstants.TEMPORARY_DESTINATION_URI_PREFIX + ClientConstants.TEMPORARY_TOPIC_URI_NAME + stompconn.getIdForTemporaryDestination();
    return new StompDestinationImpl(new Destination(name, com.sun.messaging.jmq.jmsservice.Destination.Type.TOPIC, com.sun.messaging.jmq.jmsservice.Destination.Life.TEMPORARY));
}
Also used : Destination(com.sun.messaging.jmq.jmsservice.Destination) StompDestination(com.sun.messaging.bridge.api.StompDestination)

Example 3 with Destination

use of com.sun.messaging.jmq.jmsservice.Destination in project openmq by eclipse-ee4j.

the class StompSubscriberSession method createSubscriber.

public StompSubscriber createSubscriber(StompDestination d, String selector, String duraname, boolean nolocal, StompOutputHandler out) throws Exception {
    if (consumerId != 0L) {
        throw new IllegalStateException("Subscriber already exists on this Session");
    }
    this.out = out;
    this.stompdest = stompconn.getProtocolHandler().toStompFrameDestination(d, false);
    this.duraname = duraname;
    Destination dest = ((StompDestinationImpl) d).getDestination();
    JMSServiceReply reply = null;
    try {
        reply = jmsservice.createDestination(connectionId, dest);
    } catch (JMSServiceException jmsse) {
        JMSServiceReply.Status status = jmsse.getJMSServiceReply().getStatus();
        if (status == JMSServiceReply.Status.CONFLICT) {
            if (logger.isFineLoggable() || stompconn.getProtocolHandler().getDEBUG()) {
                logger.log(logger.INFO, "Destination " + stompdest + " already exist");
            }
        } else {
            throw jmsse;
        }
    }
    reply = jmsservice.startConnection(connectionId);
    reply = jmsservice.addConsumer(connectionId, sessionId, dest, selector, duraname, (duraname != null), false, false, stompconn.getClientID(), nolocal);
    consumerId = reply.getJMQConsumerID();
    if (getDEBUG()) {
        logger.log(logger.INFO, "Created " + this);
    }
    return this;
}
Also used : Destination(com.sun.messaging.jmq.jmsservice.Destination) StompDestination(com.sun.messaging.bridge.api.StompDestination) JMSServiceReply(com.sun.messaging.jmq.jmsservice.JMSServiceReply) JMSServiceException(com.sun.messaging.jmq.jmsservice.JMSServiceException)

Aggregations

StompDestination (com.sun.messaging.bridge.api.StompDestination)3 Destination (com.sun.messaging.jmq.jmsservice.Destination)3 JMSServiceException (com.sun.messaging.jmq.jmsservice.JMSServiceException)2 JMSServiceReply (com.sun.messaging.jmq.jmsservice.JMSServiceReply)2 StompProtocolException (com.sun.messaging.bridge.api.StompProtocolException)1