List of usage examples for javax.jms DeliveryMode NON_PERSISTENT
int NON_PERSISTENT
To view the source code for javax.jms DeliveryMode NON_PERSISTENT.
Click Source Link
From source file:org.openanzo.combus.CombusConnection.java
private void performConnect() throws JMSException, AnzoException { if (connected || closing) { return;//w w w . ja v a2s . c om } if (jmsProvider == null) { throw new AnzoException(ExceptionConstants.COMBUS.NOTIFICATION_SERVICE_ERROR); } Properties propertiesNew = new Properties(); CombusProperties.setHost(propertiesNew, host); CombusProperties.setPort(propertiesNew, port); CombusProperties.setUseSsl(propertiesNew, useSsl); ConnectionFactory connectionFactory = jmsProvider.createConnectionFactory(propertiesNew); if (connectionFactory != null) { if (userName != null && password != null) { connection = connectionFactory.createConnection(userName, password); } else { connection = connectionFactory.createConnection(); } connection.setExceptionListener(new ExceptionListener() { public void onException(JMSException exception) { if (!closed) { // if user has not requested disconnect if (exception.getCause() instanceof BrokerStoppedException || exception.getCause() instanceof TransportDisposedIOException) { closed = true; } else { try { fireConnectionStateChange(INotificationConnectionListener.CONNECTIONFAILED); performDisconnect(false); } catch (AnzoException e) { log.error(LogUtils.COMBUS_MARKER, Messages.formatString(ExceptionConstants.COMBUS.JMS_DISCONNECT_FAILED), e); } finally { connected = false; } } } } }); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destinations.clear(); destinations.put(INotificationRegistrationService.SERVICE_NAME, session.createQueue(COMBUS.NOTIFICATION_SERVICE_QUEUE)); destinations.put(IModelService.SERVICE_NAME, session.createQueue(COMBUS.MODEL_SERVICE_QUEUE)); destinations.put(IAuthorizationService.SERVICE_NAME, session.createQueue(COMBUS.AUTHORIZATION_SERVICE_QUEUE)); destinations.put(IAuthenticationService.SERVICE_NAME, session.createQueue(COMBUS.AUTHENTICATION_SERVICE_QUEUE)); destinations.put(IReplicationService.SERVICE_NAME, session.createQueue(COMBUS.REPLICATION_SERVICE_QUEUE)); destinations.put(IResetService.SERVICE_NAME, session.createQueue(COMBUS.RESET_SERVICE_QUEUE)); destinations.put(IUpdateService.SERVICE_NAME, session.createQueue(COMBUS.UPDATE_SERVICE_QUEUE)); destinations.put(IQueryService.SERVICE_NAME, session.createQueue(COMBUS.QUERY_SERVICE_QUEUE)); destinations.put(IIndexService.SERVICE_NAME, session.createQueue(COMBUS.INDEX_SERVICE_QUEUE)); destinations.put(IExecutionService.SERVICE_NAME, session.createQueue(COMBUS.EXECUTION_SERVICE_QUEUE)); tempQueue = session.createTemporaryQueue(); messageProducer = session.createProducer(null); messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); messageConsumer = session.createConsumer(tempQueue); listener = new JMSMessageListener(); messageConsumer.setMessageListener(listener); connected = true; fireConnectionStateChange(INotificationConnectionListener.CONNECTED); } return; }
From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java
@Test public void testTopicNonPersistentMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = cf.createConnection(); connection.setClientID("clientId"); connection.start();/*from w w w .j a v a2 s . co m*/ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(session.createTopic(defaultTopicName)); publishTestTopicMessages(200, DeliveryMode.NON_PERSISTENT, publishedMessageSize); verifyPendingStats(defaultTopicName, 200, publishedMessageSize.get()); // consume all messages consumeTestMessages(consumer, 200); // All messages should now be gone verifyPendingStats(defaultTopicName, 0, 0); connection.close(); }
From source file:org.frameworkset.mq.RequestDispatcher.java
public void send(String msg, JMSProperties properties) throws JMSException { assertStarted();/*w w w. j a v a 2 s .c o m*/ MessageProducer producer = null; try { Destination destination = null; // if (this.destinationType == MQUtil.TYPE_QUEUE) // { // destination = session.createQueue(this.destination); // } // else // { // destination = session.createTopic(this.destination); // } LOG.debug("send message to " + this.destination + " build destination"); destination = connection.createDestination(session, this.destination, destinationType); LOG.debug("send message to " + this.destination + " build destination end."); int deliveryMode = this.persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; producer = session.createProducer(destination); Message message = createTextMessage(msg); if (properties != null) MQUtil.initMessage(message, properties); producer.send(message, deliveryMode, this.priovity, this.timetolive); 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.extensions.ifsa.jms.PullingIfsaProviderListener.java
/** * Extracts ID-string from message obtained from {@link #getRawMessage(Map)}. * Puts also the following parameters in the threadContext: * <ul>//from w ww . ja va 2 s . c om * <li>id</li> * <li>cid</li> * <li>timestamp</li> * <li>replyTo</li> * <li>messageText</li> * <li>fullIfsaServiceName</li> * <li>ifsaServiceName</li> * <li>ifsaGroup</li> * <li>ifsaOccurrence</li> * <li>ifsaVersion</li> * </ul> * @return ID-string of message for adapter. */ public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException { IFSAMessage message = null; if (rawMessage instanceof IMessageWrapper) { return getIdFromWrapper((IMessageWrapper) rawMessage, threadContext); } try { message = (IFSAMessage) rawMessage; } catch (ClassCastException e) { log.error(getLogPrefix() + "message received was not of type IFSAMessage, but [" + rawMessage.getClass().getName() + "]", e); return null; } String mode = "unknown"; String id = "unset"; String cid = "unset"; Date tsSent = null; Destination replyTo = null; String messageText = null; String fullIfsaServiceName = null; IFSAServiceName requestedService = null; String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null; try { if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) { mode = "NON_PERSISTENT"; } else if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) { mode = "PERSISTENT"; } } catch (JMSException ignore) { } // -------------------------- // retrieve MessageID // -------------------------- try { id = message.getJMSMessageID(); } catch (JMSException ignore) { } // -------------------------- // retrieve CorrelationID // -------------------------- try { cid = message.getJMSCorrelationID(); if (cid == null) { cid = id; log.debug("Setting correlation ID to MessageId"); } } catch (JMSException ignore) { } // -------------------------- // retrieve TimeStamp // -------------------------- try { long lTimeStamp = message.getJMSTimestamp(); tsSent = new Date(lTimeStamp); } catch (JMSException ignore) { } // -------------------------- // retrieve ReplyTo address // -------------------------- try { replyTo = message.getJMSReplyTo(); } catch (JMSException ignore) { } // -------------------------- // retrieve message text // -------------------------- try { messageText = ((TextMessage) message).getText(); } catch (Throwable ignore) { } // -------------------------- // retrieve ifsaServiceDestination // -------------------------- try { fullIfsaServiceName = message.getServiceString(); requestedService = message.getService(); ifsaServiceName = requestedService.getServiceName(); ifsaGroup = requestedService.getServiceGroup(); ifsaOccurrence = requestedService.getServiceOccurance(); ifsaVersion = requestedService.getServiceVersion(); } catch (JMSException e) { log.error(getLogPrefix() + "got error getting serviceparameter", e); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n JMSMessageID=[" + id + "] \n JMSCorrelationID=[" + cid + "] \n ifsaServiceName=[" + ifsaServiceName + "] \n ifsaGroup=[" + ifsaGroup + "] \n ifsaOccurrence=[" + ifsaOccurrence + "] \n ifsaVersion=[" + ifsaVersion + "] \n Timestamp Sent=[" + DateUtils.format(tsSent) + "] \n ReplyTo=[" + ((replyTo == null) ? "none" : replyTo.toString()) + "] \n MessageHeaders=[" + displayHeaders(message) + "\n" + "] \n Message=[" + message.toString() + "\n]"); } PipeLineSessionBase.setListenerParameters(threadContext, id, cid, null, tsSent); threadContext.put("timestamp", tsSent); threadContext.put("replyTo", ((replyTo == null) ? "none" : replyTo.toString())); threadContext.put("messageText", messageText); threadContext.put("fullIfsaServiceName", fullIfsaServiceName); threadContext.put("ifsaServiceName", ifsaServiceName); threadContext.put("ifsaGroup", ifsaGroup); threadContext.put("ifsaOccurrence", ifsaOccurrence); threadContext.put("ifsaVersion", ifsaVersion); Map udz = (Map) message.getIncomingUDZObject(); if (udz != null) { String contextDump = "ifsaUDZ:"; for (Iterator it = udz.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); String value = (String) udz.get(key); contextDump = contextDump + "\n " + key + "=[" + value + "]"; threadContext.put(key, value); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + contextDump); } } return id; }
From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java
@Test public void testTopicPersistentAndNonPersistentMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedNonPersistentMessageSize = new AtomicLong(); Connection connection = cf.createConnection(); connection.setClientID("clientId"); connection.start();/*from w w w .ja v a2s . c o m*/ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(session.createTopic(defaultTopicName)); publishTestTopicMessages(100, DeliveryMode.NON_PERSISTENT, publishedNonPersistentMessageSize); publishTestTopicMessages(100, DeliveryMode.PERSISTENT, publishedMessageSize); verifyPendingStats(defaultTopicName, 200, publishedMessageSize.get() + publishedNonPersistentMessageSize.get()); // consume all messages consumeTestMessages(consumer, 200); // All messages should now be gone verifyPendingStats(defaultTopicName, 0, 0); connection.close(); }
From source file:org.frameworkset.mq.RequestDispatcher.java
public void send(int destinationType, String destination_, Message message, boolean persistent, int priority, long timeToLive, JMSProperties properties) throws JMSException { assertStarted();/*from w w w. j av a 2 s . c om*/ MessageProducer producer = null; try { Destination destination = null; // if (destinationType == MQUtil.TYPE_QUEUE) // { // destination = session.createQueue(destination_); // } // else // { // destination = session.createTopic(destination_); // } LOG.debug("send message to " + destination_ + " build destination"); destination = connection.createDestination(session, destination_, destinationType); LOG.debug("send message to " + destination_ + " build destination end."); int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; producer = session.createProducer(destination); if (properties != null) MQUtil.initMessage(message, properties); producer.send(message, deliveryMode, priority, timeToLive); if (LOG.isDebugEnabled()) { LOG.debug("Sent! to destination: " + destination + " message: " + message); } message = null; } 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:org.dhatim.routing.jms.JMSRouter.java
/** * Sets the following MessageProducer properties: * <lu>/*from w ww. j av a 2 s . co m*/ * <li>TimeToLive * <li>Priority * <li>DeliveryMode * </lu> * <p> * Subclasses may override this behaviour. */ protected void setMessageProducerProperties() throws SmooksConfigurationException { try { msgProducer.setTimeToLive(jmsProperties.getTimeToLive()); msgProducer.setPriority(jmsProperties.getPriority()); final int deliveryModeInt = "non-persistent".equals(jmsProperties.getDeliveryMode()) ? DeliveryMode.NON_PERSISTENT : DeliveryMode.PERSISTENT; msgProducer.setDeliveryMode(deliveryModeInt); } catch (JMSException e) { final String errorMsg = "JMSException while trying to set JMS Header Fields"; throw new SmooksConfigurationException(errorMsg, e); } }
From source file:com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingWorker.java
private static String formatHeaders(Message message) { Destination dest = null;/*from ww w . ja va2 s. c om*/ int delMode = 0; long expiration = 0; Time expTime = null; int priority = 0; String msgID = null; long timestamp = 0; Time timestampTime = null; String correlID = null; Destination replyTo = null; boolean redelivered = false; String type = null; StringBuilder sb = new StringBuilder(); try { try { dest = message.getJMSDestination(); sb.append(" JMSDestination: "); sb.append(dest); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSDestination header\n", e); } try { delMode = message.getJMSDeliveryMode(); if (delMode == DeliveryMode.NON_PERSISTENT) { sb.append(" JMSDeliveryMode: non-persistent\n"); } else if (delMode == DeliveryMode.PERSISTENT) { sb.append(" JMSDeliveryMode: persistent\n"); } else { sb.append(" JMSDeliveryMode: neither persistent nor non-persistent; error\n"); } } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSDeliveryMode header\n", e); } try { expiration = message.getJMSExpiration(); if (expiration != 0) { expTime = new Time(expiration); sb.append(" JMSExpiration: "); sb.append(expTime); sb.append("\n"); } else { sb.append(" JMSExpiration: 0\n"); } } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSExpiration header\n", e); } try { priority = message.getJMSPriority(); sb.append(" JMSPriority: "); sb.append(priority); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSPriority header\n", e); } try { msgID = message.getJMSMessageID(); sb.append(" JMSMessageID: "); sb.append(msgID); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSMessageID header\n", e); } try { timestamp = message.getJMSTimestamp(); if (timestamp != 0) { timestampTime = new Time(timestamp); sb.append(" JMSTimestamp: "); sb.append(timestampTime); sb.append("\n"); } else { sb.append(" JMSTimestamp: 0\n"); } } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSTimestamp header\n", e); } try { correlID = message.getJMSCorrelationID(); sb.append(" JMSCorrelationID: "); sb.append(correlID); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSCorrelationID header\n", e); } try { replyTo = message.getJMSReplyTo(); sb.append(" JMSReplyTo: "); sb.append(replyTo); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSReplyTo header\n", e); } try { redelivered = message.getJMSRedelivered(); sb.append(" JMSRedelivered: "); sb.append(redelivered); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSRedelivered header\n", e); } try { type = message.getJMSType(); sb.append(" JMSType: "); sb.append(type); sb.append("\n"); } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMSType header\n", e); } } catch (Exception e) { log.log(Level.WARNING, "Unable to generate JMS headers\n", e); } return sb.toString(); }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
protected synchronized String config(ServletContext context) { String error = null;//from w w w. j a v a 2 s .c om try { props = loadConfig(); // default output format formatDefault = props.getProperty("format.default"); // editor backup save dir backupDir = props.getProperty("edit.backupDir"); // identifiers/namespaces minterDefault = props.getProperty("minters.default"); idMinters = new HashMap<String, String>(); String minterList = props.getProperty("minters.list"); String[] minterNames = minterList.split(","); for (int i = 0; i < minterNames.length; i++) { idMinters.put(minterNames[i], props.getProperty("minters." + minterNames[i])); } nsmap = TripleStoreUtil.namespaceMap(props); idNS = nsmap.get("damsid"); prNS = nsmap.get("dams"); rdfNS = nsmap.get("rdf"); madsNS = nsmap.get("mads"); // load valid class/predicate lists validClasses = loadSet(context, "/WEB-INF/valid-classes.txt"); validProperties = loadSet(context, "/WEB-INF/valid-properties.txt"); // xslt config encodingDefault = props.getProperty("solr.encoding"); xslBase = context.getRealPath("/WEB-INF/xsl") + File.separatorChar; log.info("Fedora xsl files directory: " + xslBase); // access control localCopyright = props.getProperty("role.localCopyright"); roleDefault = props.getProperty("role.default"); roleLocal = props.getProperty("role.local"); roleAdmin = props.getProperty("role.admin"); roleAdmin2 = props.getProperty("role.admin2"); roleSuper = props.getProperty("role.super"); String roleList = props.getProperty("role.list"); String[] roles = roleList.split(","); roleMap = new TreeMap<String, String[]>(); try { for (int i = 0; i < roles.length; i++) { String ipList = props.getProperty("role." + roles[i] + ".iplist"); String[] ipArray = ipList.split(","); roleMap.put(roles[i], ipArray); } } catch (Exception ex) { log.error("Error parsing roles: " + ex.toString(), ex); } // triplestores tsDefault = props.getProperty("ts.default"); tsEvents = props.getProperty("ts.events"); // files fsDefault = props.getProperty("fs.default"); fsStaging = props.getProperty("fs.staging"); maxUploadCount = getPropInt(props, "fs.maxUploadCount", -1); maxUploadSize = getPropLong(props, "fs.maxUploadSize", -1L); fsUseMap = new HashMap<String, String>(); for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); if (key != null && key.startsWith("fs.usemap.")) { String ext = key.substring(10); String use = props.getProperty(key); if (use != null) { fsUseMap.put(ext, use); } } } // fedora compat fedoraObjectDS = props.getProperty("fedora.objectDS"); fedoraRightsDS = props.getProperty("fedora.rightsDS"); fedoraLinksDS = props.getProperty("fedora.linksDS"); fedoraSystemDS = props.getProperty("fedora.systemDS"); sampleObject = props.getProperty("fedora.samplePID"); adminEmail = props.getProperty("fedora.adminEmail"); fedoraCompat = props.getProperty("fedora.compatVersion"); if (props.getProperty("fedora.debug") != null) { fedoraDebug = props.getProperty("fedora.debug").equals("true"); } // derivative list derivativesExt = props.getProperty("derivatives.ext"); String derList = props.getProperty("derivatives.list"); derivativesRes = new HashMap<String, String>(); derivativesUse = new HashMap<String, String>(); loadDerivativesConfig(derList, derivativesRes, derivativesUse); // video derivative list String derVideoList = props.getProperty("derivatives.video.list"); videoDerivativesRes = new HashMap<String, String>(); videoDerivativesUse = new HashMap<String, String>(); loadDerivativesConfig(derVideoList, videoDerivativesRes, videoDerivativesUse); // ImageMagick convert command magickCommand = props.getProperty("magick.convert"); if (magickCommand == null) magickCommand = "convert"; // Ffmpeg convert command ffmpegCommand = props.getProperty("ffmpeg"); if (ffmpegCommand == null) ffmpegCommand = "ffmpeg"; // Jhove configuration String jhoveConf = props.getProperty("jhove.conf"); if (jhoveConf != null) MyJhoveBase.setJhoveConfig(jhoveConf); // Jhove zip model configuration String jhoveZipModelCommand = props.getProperty("jhove.zipModel.command"); if (StringUtils.isNotBlank(jhoveZipModelCommand)) MyJhoveBase.setZipModelCommand(jhoveZipModelCommand); // Jhove gzip model configuration String jhoveGzipModelCommand = props.getProperty("jhove.gzipModel.command"); if (StringUtils.isNotBlank(jhoveGzipModelCommand)) MyJhoveBase.setGzipModelCommand(jhoveGzipModelCommand); jhoveMaxSize = getPropLong(props, "jhove.maxSize", -1L); // ldap for group lookup ldaputil = new LDAPUtil(props); // cache size cacheSize = getPropInt(props, "ts.cacheSize", 0); cacheClear(); // clear cache // queue queueUrl = props.getProperty("queue.url"); queueName = props.getProperty("queue.name"); if (queueEnabled && queueUrl != null) { try { queueConnectionFactory = new ActiveMQConnectionFactory(queueUrl); queueConnection = queueConnectionFactory.createConnection(); queueConnection.start(); queueSession = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); queueProducer = queueSession.createProducer(queueSession.createTopic(queueName)); queueProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); log.info("JMS Queue: " + queueUrl + "/" + queueName); } catch (Exception ex) { log.error("Error initializing JMS queue: " + ex.toString(), ex); } } // doi minter ezidTargetUrl = props.getProperty("ezid.target.url"); String ezidHost = props.getProperty("ezid.host"); String ezidShoulder = props.getProperty("ezid.shoulder"); String ezidUser = props.getProperty("ezid.user"); String ezidPass = props.getProperty("ezid.pass"); if (ezidHost != null && ezidShoulder != null && ezidUser != null && ezidPass != null) { ezid = new Ezid(ezidHost, ezidShoulder, ezidUser, ezidPass); } else { ezid = null; } // ffmpeg codec params for derivative creation ffmpegCodecParamsMap = new HashMap<String, String>(); String ffmpegCodecParams = props.getProperty("ffmpeg.codec.params"); if (StringUtils.isNotBlank(ffmpegCodecParams)) { String[] codecParams = ffmpegCodecParams.split("\\;"); for (String codecParam : codecParams) { String[] keyValPair = codecParam.trim().split("\\|"); ffmpegCodecParamsMap.put(keyValPair[0].trim(), keyValPair[1]); } } } catch (Exception ex) { log.error("Error initializing", ex); error = ex.toString(); } return error; }