コード例 #1
0
  public UMOConnector createConnector() throws Exception {
    JmsConnector connector = new JmsConnector();

    Properties props = JmsTestUtils.getJmsProperties(JmsTestUtils.SPIRIT_WAVE_JMS_PROPERTIES);
    assertNotNull("Failed to load Jms properyties", props);

    connector.setConnectionFactoryJndiName(props.getProperty("connectionFactoryJNDIName"));
    connector.setProviderProperties(props);
    connector.setName(CONNECTOR_NAME);
    connector.getDispatcherThreadingProfile().setDoThreading(false);

    return connector;
  }
コード例 #2
0
  public JmsConnector createConnector() throws Exception {
    connector = new JmsConnector();
    connector.setSpecification(JmsConstants.JMS_SPECIFICATION_11);
    connector.setConnectionFactory(getConnectionFactory());
    connector.setName(CONNECTOR_NAME);
    connector.getDispatcherThreadingProfile().setDoThreading(false);

    SimpleRetryConnectionStrategy strategy = new SimpleRetryConnectionStrategy();
    strategy.setRetryCount(5);
    strategy.setFrequency(3000);
    strategy.setDoThreading(true);
    connector.setConnectionStrategy(strategy);

    return connector;
  }
コード例 #3
0
  public void testTransactedRedeliveryToDLDestination() throws Exception {
    // there are 2 check points for each message delivered, so
    // the message will be delivered twice before this countdown will release
    final int countDownInitialCount = 4;
    final CountDownLatch countDown = new CountDownLatch(countDownInitialCount);

    // setup the component and start Mule
    UMODescriptor descriptor =
        getDescriptor("testComponent", FunctionalTestComponent.class.getName());

    EventCallback callback =
        new EventCallback() {
          public void eventReceived(UMOEventContext context, Object Component) throws Exception {
            callbackCalled = true;
            currentTx = context.getCurrentTransaction();
            assertNotNull(currentTx);
            assertTrue(currentTx.isBegun());
            System.out.println("@@@@ Rolling back transaction @@@@");
            currentTx.setRollbackOnly();
            countDown.countDown();
          }
        };

    initialiseComponent(descriptor, UMOTransactionConfig.ACTION_ALWAYS_BEGIN, callback);
    UMOManager manager = MuleManager.getInstance();
    addResultListener(getDLDest().getAddress(), countDown);

    JmsConnector umoCnn = (JmsConnector) manager.lookupConnector(CONNECTOR_NAME);

    // After redelivery retry the message and then fail
    umoCnn.setMaxRedelivery(1);

    // Set the test Exception strategy
    umoCnn.setExceptionListener(new RollbackExceptionListener(countDown, getDLDest()));

    // Start the server
    manager.start();

    // Send a test message firstso that it is there when the component is
    // started
    send(DEFAULT_MESSAGE, false, Session.AUTO_ACKNOWLEDGE);

    afterInitialise();
    countDown.tryLock(LOCK_WAIT, TimeUnit.MILLISECONDS);
    assertTrue(
        "Only "
            + (countDownInitialCount - countDown.getCount())
            + " of "
            + countDownInitialCount
            + " checkpoints hit",
        countDown.tryLock());

    assertNotNull(currentMsg);
    System.out.println(currentMsg);
    String dest = currentMsg.getStringProperty(MuleProperties.MULE_ENDPOINT_PROPERTY);
    assertNotNull(dest);
    assertEquals(getDLDest().getUri().toString(), dest);
    assertTrue(callbackCalled);

    // Make sure the message isn't on the queue
    assertNull(receive(getInDest().getAddress(), 2000));
  }