Example usage for javax.jms DeliveryMode NON_PERSISTENT

List of usage examples for javax.jms DeliveryMode NON_PERSISTENT

Introduction

In this page you can find the example usage for javax.jms DeliveryMode NON_PERSISTENT.

Prototype

int NON_PERSISTENT

To view the source code for javax.jms DeliveryMode NON_PERSISTENT.

Click Source Link

Document

This is the lowest-overhead delivery mode because it does not require that the message be logged to stable storage.

Usage

From source file:org.springframework.integration.jms.ChannelPublishingJmsMessageListener.java

/**
 * Specify the delivery mode for JMS reply Messages.
 * @see javax.jms.MessageProducer#setDeliveryMode(int)
 *///from  ww  w . ja  va  2 s .  c  o  m
public void setReplyDeliveryPersistent(boolean replyDeliveryPersistent) {
    this.replyDeliveryMode = replyDeliveryPersistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}

From source file:net.timewalker.ffmq4.local.destination.LocalQueue.java

@Override
public boolean putLocked(AbstractMessage message, LocalSession session, MessageLockSet locks)
        throws JMSException {
    checkNotClosed();//from  ww w.j  a  v a2 s  .c om
    checkTransactionLock();

    // Consistency check
    if (!message.isInternalCopy())
        throw new FFMQException("Message instance is not an FFMQ internal copy !", "CONSISTENCY_ERROR");

    // Dispatch message to the adequate store
    MessageStore targetStore;
    if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) {
        // Use volatile store if possible, otherwise fallback to persistent store
        targetStore = volatileStore != null ? volatileStore : persistentStore;
    } else
        targetStore = persistentStore;

    if (targetStore == null)
        throw new FFMQException("Queue does not support this delivery mode : "
                + (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT ? "DeliveryMode.NON_PERSISTENT"
                        : "DeliveryMode.PERSISTENT"),
                "INVALID_DELIVERY_MODE");

    int newHandle;
    synchronized (storeLock) {
        newHandle = targetStore.store(message);
        if (newHandle == -1) {
            // No space left for this message in the target store
            if (targetStore == volatileStore && persistentStore != null && queueDef.isOverflowToPersistent()) {
                // Fallback to persistent store if possible
                targetStore = persistentStore;
                newHandle = targetStore.store(message);
            }

            // Cannot store the message anywhere
            if (newHandle == -1)
                throw new DataStoreFullException("Cannot store message : queue is full : " + getName());
        }

        targetStore.lock(newHandle);
        locks.add(newHandle, targetStore.getDeliveryMode(), this, message);
    }

    if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT && requiresTransactionalUpdate()) {
        pendingChanges = true;
        return true;
    } else
        return false;
}

From source file:org.codehaus.stomp.jms.StompSession.java

protected int getDeliveryMode(Map headers) throws JMSException {
    Object o = headers.remove(Stomp.Headers.Send.PERSISTENT);
    if (o != null) {
        return "true".equals(o) ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
    } else {//  w  w w .  j a v a 2s.com
        return producer.getDeliveryMode();
    }
}

From source file:com.facetime.communication.activemq.AmqConsumer.java

public void send(Destination destination, Message message, boolean persistent, int priority, long timeToLive)
        throws JMSException {
    int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
    getProducer().send(destination, message, deliveryMode, priority, timeToLive);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sent! to destination: " + destination + " message: " + message);
    }//from w w  w  .ja  v  a  2s .  c om
}

From source file:com.adaptris.core.jms.activemq.EmbeddedActiveMq.java

public static AdaptrisMessage createMessage(AdaptrisMessageFactory fact) {
    AdaptrisMessage msg = fact == null ? AdaptrisMessageFactory.getDefaultInstance().newMessage(DEFAULT_PAYLOAD)
            : fact.newMessage(DEFAULT_PAYLOAD);
    msg.addMetadata(JmsConstants.JMS_PRIORITY, String.valueOf(HIGHEST_PRIORITY));
    msg.addMetadata(JmsConstants.JMS_DELIVERY_MODE, String.valueOf(DeliveryMode.NON_PERSISTENT));
    msg.addMetadata(JmsConstants.JMS_EXPIRATION, String.valueOf(DEFAULT_TTL));
    return msg;/* w w w  .ja va2  s.  c o m*/
}

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(int destinationType, String destination_, boolean persistent, int priority, long timeToLive,
        Message message, Logger step, JMSProperties properties) throws JMSException {
    if (step != null)
        step.logBasic("send message to " + destination_ + " assertStarted(),message=" + message);
    assertStarted();//  w  w w  . ja  v a  2  s . c  o m
    MessageProducer producer = null;
    try {
        Destination destination = null;
        //         boolean isqueue = destinationType == MQUtil.TYPE_QUEUE;
        //         if (isqueue)
        //         {
        //             if(step != null)
        //                  step.logBasic("send message to " + destination_
        //                  + " build QUEUE destination");
        //            destination = session.createQueue(destination_);
        //            if(step != null)
        //                  step.logBasic("send message to " + destination_
        //                  + " build QUEUE destination end");
        //         }
        //         else
        //         {
        //             if(step != null)
        //                  step.logBasic("send message to " + destination_
        //                  + " build Topic destination");
        //            destination = session.createTopic(destination_);
        //            if(step != null)
        //                  step.logBasic("send message to " + destination_
        //                  + " build Topic destination end");
        //         }
        if (step != null)
            step.logBasic("send message to " + destination_ + " build destination.");
        destination = this.connection.createDestination(session, destination_, destinationType);
        if (step != null)
            step.logBasic("send message to " + destination_ + " build destination end");
        int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
        if (step != null)
            step.logBasic("send message to " + destination_ + " this.client.isPersistent =" + persistent);
        if (step != null)
            step.logBasic("send message to " + destination + " send started....");
        producer = session.createProducer(destination);
        if (properties != null)
            MQUtil.initMessage(message, properties);
        producer.send(message, deliveryMode, priority, timeToLive);
        if (step != null)
            step.logBasic("send message to " + destination + " send end....");
        if (LOG.isDebugEnabled()) {
            LOG.debug("Sent! to destination: " + destination + " message: " + message);
        }
    } catch (JMSException e) {
        throw e;
    } catch (Exception e) {
        throw new JMSException(e.getMessage());
    } finally {
        if (producer != null)
            try {
                producer.close();
            } catch (Exception e) {

            }

    }
}

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

public static int stringToDeliveryMode(String mode) {
    if (MODE_PERSISTENT.equalsIgnoreCase(mode)) {
        return DeliveryMode.PERSISTENT;
    }//from  w  ww  .j  av  a2  s . c o m
    if (MODE_NON_PERSISTENT.equalsIgnoreCase(mode)) {
        return DeliveryMode.NON_PERSISTENT;
    }
    return 0;
}

From source file:org.mule.transport.jms.Jms11Support.java

public void send(MessageProducer producer, Message message, boolean persistent, int priority, long ttl,
        boolean topic, ImmutableEndpoint endpoint) throws JMSException {
    producer.send(message, (persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT), priority, ttl);
}

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

public static String deliveryModeToString(int mode) {
    if (mode == 0) {
        return "not set by application";
    }//from w  w  w. ja  v a2 s  .  c o m
    if (mode == DeliveryMode.PERSISTENT) {
        return MODE_PERSISTENT;
    }
    if (mode == DeliveryMode.NON_PERSISTENT) {
        return MODE_NON_PERSISTENT;
    }
    return "unknown delivery mode [" + mode + "]";
}

From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java

@Test
public void testQueueMessageSizeNonPersistent() throws Exception {

    AtomicLong publishedMessageSize = new AtomicLong();

    publishTestQueueMessages(200, DeliveryMode.NON_PERSISTENT, publishedMessageSize);
    verifyPendingStats(defaultQueueName, 200, publishedMessageSize.get());
    verifyPendingDurableStats(defaultQueueName, 0, 0);
}