Search in sources :

Example 1 with StompDestination

use of com.sun.messaging.bridge.api.StompDestination 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 {
    Destination dest = ((StompDestinationImpl) d).getJMSDestination();
    if (_subscriber != null) {
        throw new jakarta.jms.IllegalStateException("createSubscriber(): Unexpected call");
    }
    _out = out;
    if (dest instanceof Queue) {
        _subscriber = _session.createConsumer(dest, selector);
    } else if (duraname != null) {
        _subscriber = _session.createDurableSubscriber((Topic) dest, duraname, selector, nolocal);
        _duraName = duraname;
    } else {
        _subscriber = _session.createConsumer(dest, selector, nolocal);
    }
    return this;
}
Also used : StompDestination(com.sun.messaging.bridge.api.StompDestination)

Example 2 with StompDestination

use of com.sun.messaging.bridge.api.StompDestination in project openmq by eclipse-ee4j.

the class StompTransactedSession method createSubscriber.

public synchronized StompSubscriber createSubscriber(String subid, StompDestination d, String selector, String duraname, boolean nolocal, StompOutputHandler out) throws Exception {
    _out = out;
    Destination dest = ((StompDestinationImpl) d).getJMSDestination();
    checkSession();
    MessageConsumer sub = null;
    if (_subscribers.get(subid) != null) {
        throw new JMSException(sbr.getKString(sbr.X_SUBID_ALREADY_EXIST_IN_TXN_SESSION, subid, this.toString()));
    }
    String destname = null;
    if (dest instanceof Queue) {
        sub = session.createConsumer(dest, selector);
        destname = ((Queue) dest).getQueueName();
    } else if (duraname != null) {
        sub = session.createDurableSubscriber((Topic) dest, duraname, selector, nolocal);
        destname = ((Topic) dest).getTopicName();
    } else {
        sub = session.createConsumer(dest, selector, nolocal);
        destname = ((Topic) dest).getTopicName();
    }
    synchronized (_lock) {
        if (_subthread == null) {
            _subthread = new Thread(this);
            _subthread.setName("TransactedSession[" + this + "]");
            _subthread.setDaemon(true);
            _subthread.start();
        }
    }
    TransactedSubscriber txsub = new TransactedSubscriber(subid, sub, ((dest instanceof Queue) ? null : duraname), this);
    _subscribers.put(subid, txsub);
    String[] param = { subid, destname, this.toString() };
    logger.log(Level.INFO, sbr.getString(sbr.I_CREATED_TXN_SUB, param));
    return txsub;
}
Also used : StompDestination(com.sun.messaging.bridge.api.StompDestination)

Example 3 with StompDestination

use of com.sun.messaging.bridge.api.StompDestination 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 4 with StompDestination

use of com.sun.messaging.bridge.api.StompDestination 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 5 with StompDestination

use of com.sun.messaging.bridge.api.StompDestination 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)5 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