Search in sources :

Example 6 with ConnectionMetaData

use of javax.jms.ConnectionMetaData in project activemq-artemis by apache.

the class ConnectionTest method testGetMetadata.

@Test
public void testGetMetadata() throws Exception {
    Connection connection = createConnection();
    ConnectionMetaData metaData = connection.getMetaData();
    // TODO - need to check whether these are same as current version
    metaData.getJMSMajorVersion();
    metaData.getJMSMinorVersion();
    metaData.getJMSProviderName();
    metaData.getJMSVersion();
    metaData.getJMSXPropertyNames();
    metaData.getProviderMajorVersion();
    metaData.getProviderMinorVersion();
    metaData.getProviderVersion();
    connection.close();
}
Also used : ConnectionMetaData(javax.jms.ConnectionMetaData) Connection(javax.jms.Connection) TopicConnection(javax.jms.TopicConnection) QueueConnection(javax.jms.QueueConnection) Test(org.junit.Test)

Example 7 with ConnectionMetaData

use of javax.jms.ConnectionMetaData in project spring-boot by spring-projects.

the class JmsHealthIndicatorTests method jmsBrokerUsesFailover.

@Test
public void jmsBrokerUsesFailover() throws JMSException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    ConnectionMetaData connectionMetaData = mock(ConnectionMetaData.class);
    given(connectionMetaData.getJMSProviderName()).willReturn("JMS test provider");
    Connection connection = mock(Connection.class);
    given(connection.getMetaData()).willReturn(connectionMetaData);
    willThrow(new JMSException("Could not start", "123")).given(connection).start();
    given(connectionFactory.createConnection()).willReturn(connection);
    JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory);
    Health health = indicator.health();
    assertThat(health.getStatus()).isEqualTo(Status.DOWN);
    assertThat(health.getDetails().get("provider")).isNull();
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) ConnectionMetaData(javax.jms.ConnectionMetaData) Connection(javax.jms.Connection) JMSException(javax.jms.JMSException) Test(org.junit.Test)

Example 8 with ConnectionMetaData

use of javax.jms.ConnectionMetaData in project iaf by ibissource.

the class JmsMessagingSourceFactory method getConnectionFactoryInfo.

public String getConnectionFactoryInfo(ConnectionFactory connectionFactory) {
    if ("TIBCOAMX".equals(applicationServerType)) {
        // javax.resource.ResourceException: JMSJCA-E084: Failed to create session: The JNDI name is null
        return null;
    }
    String info = null;
    Connection connection = null;
    try {
        connection = connectionFactory.createConnection();
        ConnectionMetaData metaData = connection.getMetaData();
        info = "jms provider name [" + metaData.getJMSProviderName() + "] jms provider version [" + metaData.getProviderVersion() + "] jms version [" + metaData.getJMSVersion() + "]";
    } catch (JMSException e) {
        log.warn("Exception determining connection factory info", e);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (JMSException e1) {
                log.warn("Exception closing connection for metadata", e1);
            }
        }
    }
    return info;
}
Also used : ConnectionMetaData(javax.jms.ConnectionMetaData) Connection(javax.jms.Connection) TopicConnection(javax.jms.TopicConnection) QueueConnection(javax.jms.QueueConnection) JMSException(javax.jms.JMSException)

Example 9 with ConnectionMetaData

use of javax.jms.ConnectionMetaData in project qpid-broker-j by apache.

the class QpidRestAPIQueueCreator method getProtocolVersion.

@Override
public String getProtocolVersion(final Connection connection) {
    if (connection != null) {
        try {
            // Qpid 0-8..0-10 method only
            final Method method = connection.getClass().getMethod("getProtocolVersion");
            Object version = method.invoke(connection);
            return String.valueOf(version);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            try {
                ConnectionMetaData metaData = connection.getMetaData();
                if (metaData != null && ("QpidJMS".equals(metaData.getJMSProviderName()) || "AMQP.ORG".equals(metaData.getJMSProviderName()))) {
                    return "1.0";
                }
            } catch (JMSException e1) {
                return null;
            }
            return null;
        }
    }
    return null;
}
Also used : ConnectionMetaData(javax.jms.ConnectionMetaData) JMSException(javax.jms.JMSException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ConnectionMetaData (javax.jms.ConnectionMetaData)9 Test (org.junit.Test)6 Connection (javax.jms.Connection)5 JMSException (javax.jms.JMSException)5 ConnectionFactory (javax.jms.ConnectionFactory)3 Enumeration (java.util.Enumeration)2 QueueConnection (javax.jms.QueueConnection)2 TopicConnection (javax.jms.TopicConnection)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1 Attributes (java.util.jar.Attributes)1 JarFile (java.util.jar.JarFile)1 Manifest (java.util.jar.Manifest)1 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)1 ActiveMQConnectionMetaData (org.apache.activemq.artemis.jms.client.ActiveMQConnectionMetaData)1