Example usage for javax.jms Destination getClass

List of usage examples for javax.jms Destination getClass

Introduction

In this page you can find the example usage for javax.jms Destination getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:hermes.Domain.java

public static Domain getDomain(Destination destination) {
    if (destination instanceof Queue && destination instanceof Topic) {
        ///*from   www  . ja  v a2  s.  co  m*/
        // This is an interesting hack to deal with WebLogic as it implements both domains. If we see the object 
        // is somewhere in the WLS JMS packages then see if we can get the "topic" property. We must do this dynamically
        // as it may be loaded in a different class loader (so instanceof will fail) AND we don't want this part of the
        // Hermes codebase to be coupled to any provider.

        if (destination.getClass().getName().startsWith("weblogic.jms")) {
            try {
                final Boolean isTopic = (Boolean) PropertyUtils.getProperty(destination, "topic");

                return isTopic ? Domain.TOPIC : Domain.QUEUE;
            } catch (Throwable e) {
                log.error(e.getMessage(), e);

                return Domain.UNKNOWN;
            }
        } else {
            return Domain.UNKNOWN;
        }
    } else if (destination instanceof Queue) {
        return Domain.QUEUE;
    } else {
        return Domain.TOPIC;
    }
}

From source file:nl.nn.adapterframework.jms.JMSFacade.java

public String send(Session session, Destination dest, String correlationId, String message, String messageType,
        long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException,
        Map properties) throws NamingException, JMSException, SenderException {
    TextMessage msg = createTextMessage(session, correlationId, message);
    MessageProducer mp;//from   w  w w. j a v a2s  .c  om
    try {
        if (useJms102()) {
            if ((session instanceof TopicSession) && (dest instanceof Topic)) {
                mp = getTopicPublisher((TopicSession) session, (Topic) dest);
            } else {
                if ((session instanceof QueueSession) && (dest instanceof Queue)) {
                    mp = getQueueSender((QueueSession) session, (Queue) dest);
                } else {
                    throw new SenderException(
                            "classes of Session [" + session.getClass().getName() + "] and Destination ["
                                    + dest.getClass().getName() + "] do not match (Queue vs Topic)");
                }
            }
        } else {
            mp = session.createProducer(dest);
        }
    } catch (InvalidDestinationException e) {
        if (ignoreInvalidDestinationException) {
            log.warn("queue [" + dest + "] doesn't exist");
            return null;
        } else {
            throw e;
        }
    }
    if (messageType != null) {
        msg.setJMSType(messageType);
    }
    if (deliveryMode > 0) {
        msg.setJMSDeliveryMode(deliveryMode);
        mp.setDeliveryMode(deliveryMode);
    }
    if (priority >= 0) {
        msg.setJMSPriority(priority);
        mp.setPriority(priority);
    }
    if (timeToLive > 0) {
        mp.setTimeToLive(timeToLive);
    }
    if (properties != null) {
        for (Iterator it = properties.keySet().iterator(); it.hasNext();) {
            String key = (String) it.next();
            Object value = properties.get(key);
            log.debug("setting property [" + name + "] to value [" + value + "]");
            msg.setObjectProperty(key, value);
        }
    }
    String result = send(mp, msg, ignoreInvalidDestinationException);
    mp.close();
    return result;
}

From source file:org.apache.activemq.JmsQueueCompositeSendReceiveTest.java

/**
 * Test if all the messages sent are being received.
 *
 * @throws Exception//from w  w  w.  ja  v  a  2  s. c o  m
 */
public void testSendReceive() throws Exception {
    super.testSendReceive();
    messages.clear();
    Destination consumerDestination = consumeSession.createQueue("FOO.BAR.HUMBUG2");
    LOG.info("Created  consumer destination: " + consumerDestination + " of type: "
            + consumerDestination.getClass());
    MessageConsumer consumer = null;
    if (durable) {
        LOG.info("Creating durable consumer");
        consumer = consumeSession.createDurableSubscriber((Topic) consumerDestination, getName());
    } else {
        consumer = consumeSession.createConsumer(consumerDestination);
    }
    consumer.setMessageListener(this);

    assertMessagesAreReceived();
    LOG.info("" + data.length + " messages(s) received, closing down connections");
}