javax.jms.ConnectionMetaData Java Examples

The following examples show how to use javax.jms.ConnectionMetaData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JMSXPropertyTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Test that the JMSX property <code>JMSXGroupID</code> is supported.
 */
@Test
public void testSupportsJMSXGroupID() {
   try {
      boolean found = false;
      ConnectionMetaData metaData = senderConnection.getMetaData();
      Enumeration enumeration = metaData.getJMSXPropertyNames();
      while (enumeration.hasMoreElements()) {
         String jmsxPropertyName = (String) enumeration.nextElement();
         if (jmsxPropertyName.equals("JMSXGroupID")) {
            found = true;
         }
      }
      Assert.assertTrue("JMSXGroupID property is not supported", found);
   } catch (JMSException e) {
      fail(e);
   }
}
 
Example #2
Source File: ManifestTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testManifestEntries() throws Exception {
   Properties props = System.getProperties();
   String userDir = props.getProperty("build.lib");

   UnitTestLogger.LOGGER.trace("userDir is " + userDir);

   // The jar must be there
   File file = new File("build/jars", "activemq-core.jar");
   Assert.assertTrue(file.exists());

   // Open the jar and load MANIFEST.MF
   JarFile jar = new JarFile(file);
   Manifest manifest = jar.getManifest();

   ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());

   ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());

   // Compare the value from ConnectionMetaData and MANIFEST.MF
   Attributes attrs = manifest.getMainAttributes();

   Assert.assertEquals(meta.getProviderVersion(), attrs.getValue("ActiveMQ-Version"));
}
 
Example #3
Source File: JmsConnectionTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test(timeout=30000)
public void testConnectionMetaData() throws Exception {
    connection = new JmsConnection(connectionInfo, provider);

    ConnectionMetaData metaData = connection.getMetaData();

    assertNotNull(metaData);
    assertEquals(2, metaData.getJMSMajorVersion());
    assertEquals(0, metaData.getJMSMinorVersion());
    assertEquals("2.0", metaData.getJMSVersion());
    assertNotNull(metaData.getJMSXPropertyNames());

    assertNotNull(metaData.getProviderVersion());
    assertNotNull(metaData.getJMSProviderName());

    int major = metaData.getProviderMajorVersion();
    int minor = metaData.getProviderMinorVersion();
    assertTrue("Expected non-zero provider major(" + major + ") / minor(" + minor +") version.", (major + minor) != 0);
}
 
Example #4
Source File: AmqpManagementTest.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
private boolean isSupportedClient() throws NamingException, JMSException
{
    if (getProtocol() == Protocol.AMQP_1_0)
    {
        return true;
    }
    else
    {
        Connection con = getConnection();
        try
        {
            final ConnectionMetaData metaData = con.getMetaData();
            // Older Qpid JMS Client 0-x (<=6.1.x) didn't support management addresses.
            return !(metaData.getProviderMajorVersion() < 6 || (metaData.getProviderMajorVersion() == 6
                                                                    && metaData.getProviderMinorVersion() <= 1));
        }
        finally
        {
            con.close();
        }
    }

}
 
Example #5
Source File: ConnectionTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #6
Source File: ClientJmsDelegate.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
private String metaDataToString(ConnectionMetaData metaData) throws JMSException
{
    StringBuilder sb = new StringBuilder("ConnectionMetaData[");
    sb.append(" JMSProviderName : " + metaData.getJMSProviderName());
    sb.append(" JMSVersion : " + metaData.getJMSVersion() + " (" + metaData.getJMSMajorVersion() + "." + metaData.getJMSMinorVersion() +")");
    sb.append(" ProviderVersion : " + metaData.getProviderVersion()+ " (" + metaData.getProviderMajorVersion()+ "." + metaData.getProviderMinorVersion() +")" );
    sb.append(" JMSXPropertyNames : [");
    Enumeration en = metaData.getJMSXPropertyNames();
    while(en.hasMoreElements())
    {
        sb.append(" ").append(en.nextElement());
        if( en.hasMoreElements())
        {
            sb.append(",");
        }
    }
    sb.append("]]");
    return sb.toString();
}
 
Example #7
Source File: ActiveMQJMSContext.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
   try {
      return connection.getMetaData();
   } catch (JMSException e) {
      throw JmsExceptionUtils.convertToRuntimeException(e);
   }
}
 
Example #8
Source File: ActiveMQConnection.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException {
   checkClosed();

   if (metaData == null) {
      metaData = new ActiveMQConnectionMetaData(thisVersion);
   }

   return metaData;
}
 
Example #9
Source File: JmsContext.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
    try {
        return connection.getMetaData();
    } catch (JMSException jmse) {
        throw JmsExceptionSupport.createRuntimeException(jmse);
    }
}
 
Example #10
Source File: JMSXPropertyTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * checks if the JMSX property <code>JMSXDeliveryCount</code> is supported.
 */
private boolean supportsJMSXDeliveryCount() throws Exception {
   ConnectionMetaData metaData = senderConnection.getMetaData();
   Enumeration enumeration = metaData.getJMSXPropertyNames();
   while (enumeration.hasMoreElements()) {
      String jmsxPropertyName = (String) enumeration.nextElement();
      if (jmsxPropertyName.equals("JMSXDeliveryCount")) {
         return true;
      }
   }
   return false;
}
 
Example #11
Source File: QpidRestAPIQueueCreator.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public String getProtocolVersion(final Connection connection)
{
    if (connection != null)
    {
        try
        {
            final Method method = connection.getClass().getMethod("getProtocolVersion"); // Qpid 0-8..0-10 method only
            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;
}
 
Example #12
Source File: JmsMessagingSourceFactory.java    From iaf with Apache License 2.0 5 votes vote down vote up
public String getConnectionFactoryInfo(ConnectionFactory connectionFactory) {
	if (IbisContext.getApplicationServerType().equals("TIBCOAMX")) {
		// Workaround to prevent the following exception:
		// [org.apache.geronimo.connector.outbound.MCFConnectionInterceptor] - Error occurred creating ManagedConnection for org.apache.geronimo.connector.outbound.ConnectionInfo@#######
		// 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;
}
 
Example #13
Source File: MockJMSContext.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
    try {
        return connection.getMetaData();
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
Example #14
Source File: JMSContextImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
    try {
        return connection().getMetaData();
    } catch (final JMSException e) {
        throw toRuntimeException(e);
    }
}
 
Example #15
Source File: JmsPoolJMSContext.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
    try {
        return connection.getMetaData();
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
Example #16
Source File: ActiveMQRASessionFactoryImpl.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the connection metadata
 *
 * @return The connection metadata
 * @throws JMSException Thrown if an error occurs
 */
@Override
public ConnectionMetaData getMetaData() throws JMSException {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getMetaData()");
   }

   checkClosed();
   return mcf.getMetaData();
}
 
Example #17
Source File: ActiveMQRAManagedConnectionFactory.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the connection metadata
 *
 * @return The metadata
 */
public ConnectionMetaData getMetaData() {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getMetadata()");
   }

   return new ActiveMQRAConnectionMetaData();
}
 
Example #18
Source File: JMSDestinationTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException {
    return delegate.getMetaData();
}
 
Example #19
Source File: JmsConnection.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException {
    checkClosedOrFailed();
    return JmsConnectionMetaData.INSTANCE;
}
 
Example #20
Source File: TracingConnection.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public ConnectionMetaData getMetaData() throws JMSException {
  return delegate.getMetaData();
}
 
Example #21
Source File: ProxyConnection.java    From lemon with Apache License 2.0 4 votes vote down vote up
public ConnectionMetaData getMetaData() throws JMSException {
    return null;
}
 
Example #22
Source File: JMS2CDIExtension.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() {
    return context().getMetaData();
}
 
Example #23
Source File: TracingJMSContext.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public ConnectionMetaData getMetaData() {
  return delegate.getMetaData();
}
 
Example #24
Source File: TestConnection.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException {
	return null;
}
 
Example #25
Source File: FakeConnection.java    From kieker with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionMetaData getMetaData() throws JMSException {
	return null;
}
 
Example #26
Source File: FakeConnection.java    From kieker with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ConnectionMetaData getMetaData() throws JMSException {
	return null;
}
 
Example #27
Source File: TestJMSConnection.java    From development with Apache License 2.0 4 votes vote down vote up
public ConnectionMetaData getMetaData() throws JMSException {
    throw new UnsupportedOperationException();
}
 
Example #28
Source File: ConnectionStub.java    From development with Apache License 2.0 4 votes vote down vote up
public ConnectionMetaData getMetaData() throws JMSException {
    throw new UnsupportedOperationException();
}
 
Example #29
Source File: RefCountedJmsXaConnection.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException
{
    return underlying.getMetaData();
}
 
Example #30
Source File: TestConnection.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionMetaData getMetaData() throws JMSException {
	return null;
}