當前位置: 首頁>>代碼示例>>Java>>正文


Java JMSException類代碼示例

本文整理匯總了Java中javax.jms.JMSException的典型用法代碼示例。如果您正苦於以下問題:Java JMSException類的具體用法?Java JMSException怎麽用?Java JMSException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JMSException類屬於javax.jms包,在下文中一共展示了JMSException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFailedCreateConsumerConnectionStillWorks

import javax.jms.JMSException; //導入依賴的package包/類
@Test
public void testFailedCreateConsumerConnectionStillWorks() throws JMSException {
    Connection connection = pooledConnFact.createConnection("guest", "password");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue(name.getMethodName());

    try {
        session.createConsumer(queue);
        fail("Should fail to create consumer");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    queue = session.createQueue("GUESTS." + name.getMethodName());

    MessageProducer producer = session.createProducer(queue);
    producer.close();

    connection.close();
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:23,代碼來源:PooledConnectionSecurityExceptionTest.java

示例2: populateMessageProperties

import javax.jms.JMSException; //導入依賴的package包/類
/**
 * Add any properties (name/value pairs) to the message as string properties
 * @param message properties will be added here
 * @param props the set of additional properties to be added to message.
 * NOTE: If values other than strings need to be added to Messages this 
 * method can be refactored to support.
 */
private void populateMessageProperties(Message message, Properties props){
    if(props == null || message == null){
        return;
    }

    Set<String> propNames = props.stringPropertyNames();
    try{
        for(String propName : propNames){
            String value = props.getProperty(propName);
            if(value != null){
                message.setStringProperty(propName, value);
            }
        }
    }catch(JMSException jmse){
        log.error("Problem added properties to Message", jmse);
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:25,代碼來源:JmsClientHelper.java

示例3: doTestCreateMessageProducer

import javax.jms.JMSException; //導入依賴的package包/類
private void doTestCreateMessageProducer(boolean useAnonymousProducers) throws JMSException {
    cf.setUseAnonymousProducers(useAnonymousProducers);

    JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    Queue queue1 = session.createTemporaryQueue();
    Queue queue2 = session.createTemporaryQueue();

    JmsPoolMessageProducer producer1 = (JmsPoolMessageProducer) session.createProducer(queue1);
    JmsPoolMessageProducer producer2 = (JmsPoolMessageProducer) session.createProducer(queue2);

    if (useAnonymousProducers) {
        assertSame(producer1.getMessageProducer(), producer2.getMessageProducer());
    } else {
        assertNotSame(producer1.getMessageProducer(), producer2.getMessageProducer());
    }

    connection.close();
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:21,代碼來源:JmsPoolWrappedProducersTest.java

示例4: doSendBinaryMessage

import javax.jms.JMSException; //導入依賴的package包/類
private void doSendBinaryMessage( final Session session, final Destination destination,
                                  final byte[] bytes,
                                  final Map<String, ?> properties ) throws JMSException {

    try {
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(bytes);
        if (properties != null) {
            // Note: Setting any properties (including JMS fields) using
            // setObjectProperty might not be supported by all providers
            // Tested with: ActiveMQ
            for (final Entry<String, ?> property : properties.entrySet()) {
                message.setObjectProperty(property.getKey(), property.getValue());
            }
        }
        final MessageProducer producer = session.createProducer(destination);
        producer.send(message);
    } finally {
        releaseSession(false);
    }
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:22,代碼來源:JmsClient.java

示例5: createTopicConsumer

import javax.jms.JMSException; //導入依賴的package包/類
public MessageConsumer createTopicConsumer(String selector) throws JMSException {
	if (isQueue) {
		throw new IllegalArgumentException("Only for topic, not queue");
	}
	String consumerId = "consumer-" + UUID.randomUUID();
	topicConnection = startConnection(consumerId);
	Session session = topicConnection.createSession(isTransacted, Session.AUTO_ACKNOWLEDGE);
	Topic topic = session.createTopic(destinationName);
	if (isDurable) {
		if (selector != null) {
			return session.createDurableSubscriber(topic, consumerId, selector, true);
		} else {
			return session.createDurableSubscriber(topic, consumerId);
		}
	} else {
		if (selector != null) {
			return session.createConsumer(topic, selector);
		} else {
			return session.createConsumer(topic);
		}
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:23,代碼來源:JmsClient.java

示例6: publishMessage

import javax.jms.JMSException; //導入依賴的package包/類
/**
 *
 * @throws JMSException
 */
public void publishMessage(CmsWorkOrderSimpleBase cmsWoSimpleBase, String type, String id)
    throws JMSException {
  if (isPubEnabled) {
    long t1 = System.currentTimeMillis();
    cmsWoSimpleBase = CmsUtil.maskSecuredFields(cmsWoSimpleBase, type);
    String payload = gson.toJson(cmsWoSimpleBase);
    Map<String, String> headers = new HashMap<>(2);
    headers.put("type", getType(type));
    headers.put("msgId", id);
    MessageData data = new MessageData(payload, headers);
    searchPublisher.publish(data);
    if (cmsWoSimpleBase instanceof CmsWorkOrderSimple) {
      logger.info("WO published to search stream queue for RfcId: "
          + ((CmsWorkOrderSimple) cmsWoSimpleBase).getRfcId() + " took " + (
          System.currentTimeMillis() - t1));
    } else if (cmsWoSimpleBase instanceof CmsActionOrderSimple) {
      logger.info("AO published to search stream queue for procedureId/actionId: "
          + ((CmsActionOrderSimple) cmsWoSimpleBase).getProcedureId() + "/"
          + ((CmsActionOrderSimple) cmsWoSimpleBase).getActionId() + " took " + (
          System.currentTimeMillis() - t1));
    }
  } else {
    logger.warn(">>>WOPublisher is disabled<IS_SEARCH_ENABLED>"+ isPubEnabled);
  }
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:WoPublisher.java

示例7: createManagedConnection

import javax.jms.JMSException; //導入依賴的package包/類
private ManagedConnection createManagedConnection() {

        final ManagedConnection connection;
        final ConnectionFactory connectionFactory = getConnectionFactory();
        try {
            if (!StringUtils.isNullOrEmpty(this.username)) {
                connection = ManagedConnection.create(connectionFactory.createConnection(this.username,
                                                                                         this.password));
            } else {
                connection = ManagedConnection.create(connectionFactory.createConnection());
            }
        } catch (JMSException e) {
            throw new JmsMessageException("Error creating JMS connection from connection factory '"
                                          + defaultConnectionFactoryName + "'", e);
        }
        return connection;
    }
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:18,代碼來源:JmsClient.java

示例8: isValidRequestResponse

import javax.jms.JMSException; //導入依賴的package包/類
/**
 * Since we use a request/response communication style with the client,
 * we must ensure that tha appropriate fields are set.
 */
private boolean isValidRequestResponse(Message incoming) {
    try {
        if (incoming.getJMSCorrelationID() == null) {
            getLogger().warn("JMSCorrelationID is not set! Will not process request");
            return false;
        }

        if (incoming.getJMSReplyTo() == null) {
            getLogger().warn("JMSReplyTo is not set! Will not process request");
            return false;
        }
    } catch (JMSException e) {
        getLogger().warn(
                "Failed to read JMSCorrelationID/JMSReplyTo. " +
                "Will not process request. Exception message = {}", e.getMessage());
        return false;
    }

    return true;
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:xsharing-services-router,代碼行數:25,代碼來源:AbstractSharingListener.java

示例9: createConsumer

import javax.jms.JMSException; //導入依賴的package包/類
@Override
public JMSConsumer createConsumer(Destination destination, String selector, boolean noLocal) {
    try {
        return startIfNeeded(new JMSConsumerImpl(this, getSession().createConsumer(destination, selector, noLocal)));
    } catch (JMSException jmse) {
        throw Utils.convertToRuntimeException(jmse);
    }
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:9,代碼來源:JMSContextImpl.java

示例10: sendMessage

import javax.jms.JMSException; //導入依賴的package包/類
public void sendMessage(MessageContext messageContext,
        Destination destination, Message message) throws JMSException {
    String destinationName = destination.toString();

    if (destination instanceof Topic) {
        messageHandler.sendMessageToTopic(messageContext, destinationName,
                message);
    } else {
        messageHandler.sendMessageToQueue(messageContext, destinationName,
                message);
    }
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:13,代碼來源:ProxyConnectionFactory.java

示例11: fail_on_get_property

import javax.jms.JMSException; //導入依賴的package包/類
@Test
public void fail_on_get_property() throws Exception {
    when(message.getPropertyNames()).thenReturn(Collections.enumeration(asList("1", "2", "3")));
    when(message.getStringProperty("1")).thenReturn("1");
    when(message.getStringProperty("2")).thenThrow(JMSException.class);
    propagator.copyFromMessage(message);
    verify(message).getStringProperty(eq("1"));
    verify(message).getStringProperty(eq("2"));
    verify(message, never()).getStringProperty(eq("3"));
    Assert.assertThat(current().containsKey("1"), is(true));
    Assert.assertThat(current().entrySet().size(), is(1));
}
 
開發者ID:enadim,項目名稱:spring-cloud-ribbon-extensions,代碼行數:13,代碼來源:AbstractPreservesMessagePropertiesTest.java

示例12: createQueueSession

import javax.jms.JMSException; //導入依賴的package包/類
@Override
public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
    checkClosedOrFailed();
    ensureConnected();
    int ackMode = getSessionAcknowledgeMode(transacted, acknowledgeMode);
    MockJMSQueueSession result = new MockJMSQueueSession(getNextSessionId(), ackMode, this);
    addSession(result);
    if (started.get()) {
        result.start();
    }
    return result;
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:13,代碼來源:MockJMSConnection.java

示例13: convergeIfNeeded

import javax.jms.JMSException; //導入依賴的package包/類
@Override
@Transactional
public void convergeIfNeeded(CmsActionOrderSimple ao) throws JMSException {
  long procId = ao.getProcedureId();
  long ciId = ao.getCiId();
  String logPrefix = "procedure " + procId + " ci " + ciId;
  int step = ao.getExecOrder();
  if (canConverge(ao.getProcedureId(), ao.getCiId(), step)) {
    //send a jms message to controller.workflow queue to proceed to next step
    logger.info("procedure " + procId + " ciId " + ciId + ": inductor response converging to next step");
    sendMessageToProceed(PROCEDURE.getName(), procId);
  }
  logger.info(logPrefix + " inductor response processing finished");
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:15,代碼來源:ProcedureRunnerImpl.java

示例14: newJMSException

import javax.jms.JMSException; //導入依賴的package包/類
public static JMSException newJMSException(Throwable t) {
    if (t instanceof JMSException) {
        return (JMSException) t;
    }
    JMSException se = new JMSException(t.getMessage());
    return (JMSException) se.initCause(t);
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:8,代碼來源:Utils.java

示例15: setBytes

import javax.jms.JMSException; //導入依賴的package包/類
@Override
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
    // Fail early to avoid unnecessary array copy.
    checkKeyNameIsValid(name);

    byte[] clone = null;
    if (value != null) {
        clone = new byte[length];
        System.arraycopy(value, offset, clone, 0, length);
    }

    put(name, clone);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:14,代碼來源:MockJMSMapMessage.java


注:本文中的javax.jms.JMSException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。