@Override public RoutingStatus route(final Message message, final Transaction tx, final boolean direct, final boolean rejectDuplicates, final Binding binding) throws Exception { return route(message, new RoutingContextImpl(tx), direct, rejectDuplicates, binding); }
@Override public RoutingStatus route(final Message message, final Transaction tx, final boolean direct) throws Exception { return route(message, new RoutingContextImpl(tx), direct); }
private void sendToQueue(Message message, Queue queue, Transaction tx) throws Exception { RoutingContext context = new RoutingContextImpl(tx); queue.route(message, context); session.getServer().getPostOffice().processRoute(message, context, false); } }
private void sendToQueue(Message message, Queue queue, Transaction tx) throws Exception { RoutingContext context = new RoutingContextImpl(tx); queue.route(message, context); session.getServer().getPostOffice().processRoute(message, context, false); } }
private void routeQueueInfo(final Message message, final Queue queue, final boolean applyFilters) throws Exception { if (!applyFilters || queue.getFilter() == null || queue.getFilter().match(message)) { RoutingContext context = new RoutingContextImpl(null); queue.route(message, context); processRoute(message, context, false); } }
RoutingContext routingContext = new RoutingContextImpl(tx);
RoutingContext context = new RoutingContextImpl(tx);
postOffice.route(copy, new RoutingContextImpl(context.getTransaction()).setReusable(false), false);
protected final RoutingContext routingContext = new RoutingContextImpl(null);
private void internalTest(final boolean route) throws Exception { final FakeBinding fake = new FakeBinding(new SimpleString("a")); final Bindings bind = new BindingsImpl(null, null); bind.addBinding(fake); bind.addBinding(new FakeBinding(new SimpleString("a"))); bind.addBinding(new FakeBinding(new SimpleString("a"))); Thread t = new Thread() { @Override public void run() { try { bind.removeBinding(fake); } catch (Exception e) { e.printStackTrace(); } } }; Queue queue = new FakeQueue(new SimpleString("a")); t.start(); for (int i = 0; i < 100; i++) { if (route) { bind.route(new CoreMessage(i, 100), new RoutingContextImpl(new FakeTransaction())); } else { bind.redistribute(new CoreMessage(i, 100), queue, new RoutingContextImpl(new FakeTransaction())); } } }
@Test public void testPagingManager() throws Exception { HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<>(); addressSettings.setDefault(new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE)); final StorageManager storageManager = new NullStorageManager(); PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, getPageDirFile(), 100, null, getOrderedExecutor(), true, null); PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings); managerImpl.start(); PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test")); ICoreMessage msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10)); final RoutingContextImpl ctx = new RoutingContextImpl(null); Assert.assertFalse(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock)); store.startPaging(); Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock)); Page page = store.depage(); page.open(); List<PagedMessage> msgs = page.read(new NullStorageManager()); page.close(); Assert.assertEquals(1, msgs.size()); ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), (msgs.get(0).getMessage()).toCore().getBodyBuffer().toByteBuffer().array()); Assert.assertTrue(store.isPaging()); Assert.assertNull(store.depage()); final RoutingContextImpl ctx2 = new RoutingContextImpl(null); Assert.assertFalse(store.page(msg, ctx2.getTransaction(), ctx2.getContextListing(store.getStoreName()), lock)); }
final RoutingContextImpl ctx = new RoutingContextImpl(null); Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock)); final RoutingContextImpl ctx = new RoutingContextImpl(null); Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock)); final RoutingContextImpl ctx2 = new RoutingContextImpl(null); Assert.assertFalse(store.page(msg, ctx2.getTransaction(), ctx2.getContextListing(store.getStoreName()), lock)); final RoutingContextImpl ctx2 = new RoutingContextImpl(null); Assert.assertTrue(store.page(msg, ctx2.getTransaction(), ctx2.getContextListing(store.getStoreName()), lock));
final RoutingContextImpl ctx = new RoutingContextImpl(null); Assert.assertTrue(storeImpl.page(msg, ctx.getTransaction(), ctx.getContextListing(storeImpl.getStoreName()), lock));
final RoutingContextImpl ctx = new RoutingContextImpl(null); storeImpl2.page(lastMsg, ctx.getTransaction(), ctx.getContextListing(storeImpl2.getStoreName()), lock); buffers2.put(lastMessageId, lastMsg);
@Test public void testStore() throws Exception { SequentialFileFactory factory = new FakeSequentialFileFactory(); PagingStoreFactory storeFactory = new FakeStoreFactory(factory); AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); PagingStore storeImpl = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100, createMockManager(), createStorageManagerMock(), factory, storeFactory, PagingStoreImplTest.destinationTestName, addressSettings, getExecutorFactory().getExecutor(), true); storeImpl.start(); Assert.assertEquals(0, storeImpl.getNumberOfPages()); storeImpl.startPaging(); Assert.assertEquals(1, storeImpl.getNumberOfPages()); List<ActiveMQBuffer> buffers = new ArrayList<>(); ActiveMQBuffer buffer = createRandomBuffer(0, 10); buffers.add(buffer); SimpleString destination = new SimpleString("test"); Message msg = createMessage(1, storeImpl, destination, buffer); Assert.assertTrue(storeImpl.isPaging()); final RoutingContextImpl ctx = new RoutingContextImpl(null); Assert.assertTrue(storeImpl.page(msg, ctx.getTransaction(), ctx.getContextListing(storeImpl.getStoreName()), lock)); Assert.assertEquals(1, storeImpl.getNumberOfPages()); storeImpl.sync(); storeImpl = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100, createMockManager(), createStorageManagerMock(), factory, storeFactory, PagingStoreImplTest.destinationTestName, addressSettings, getExecutorFactory().getExecutor(), true); storeImpl.start(); Assert.assertEquals(1, storeImpl.getNumberOfPages()); }