org.apache.activemq.artemis.api.core.SimpleString Java Examples

The following examples show how to use org.apache.activemq.artemis.api.core.SimpleString. 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: BridgeControlTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotifications() throws Exception {
   SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
   BridgeControl bridgeControl = createBridgeControl(bridgeConfig.getName(), mbeanServer);

   server_0.getManagementService().addNotificationListener(notifListener);

   Assert.assertEquals(0, notifListener.getNotifications().size());

   bridgeControl.stop();

   Assert.assertEquals(1, notifListener.getNotifications().size());
   Notification notif = notifListener.getNotifications().get(0);
   Assert.assertEquals(CoreNotificationType.BRIDGE_STOPPED, notif.getType());
   Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());

   bridgeControl.start();

   Assert.assertEquals(2, notifListener.getNotifications().size());
   notif = notifListener.getNotifications().get(1);
   Assert.assertEquals(CoreNotificationType.BRIDGE_STARTED, notif.getType());
   Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
 
Example #2
Source File: PostOfficeImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public AddressInfo updateAddressInfo(SimpleString addressName,
                                     EnumSet<RoutingType> routingTypes) throws Exception {
   synchronized (this) {
      if (server.hasBrokerAddressPlugins()) {
         server.callBrokerAddressPlugins(plugin -> plugin.beforeUpdateAddress(addressName, routingTypes));
      }

      final AddressInfo address = addressManager.updateAddressInfo(addressName, routingTypes);
      if (server.hasBrokerAddressPlugins()) {
         server.callBrokerAddressPlugins(plugin -> plugin.afterUpdateAddress(address));
      }

      return address;
   }
}
 
Example #3
Source File: TypedPropertiesConversionTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testBooleanProperty() throws Exception {
   Boolean val = RandomUtil.randomBoolean();
   props.putBooleanProperty(key, val);

   Assert.assertEquals(val, props.getBooleanProperty(key));
   Assert.assertEquals(new SimpleString(Boolean.toString(val)), props.getSimpleStringProperty(key));

   props.putSimpleStringProperty(key, new SimpleString(Boolean.toString(val)));
   Assert.assertEquals(val, props.getBooleanProperty(key));

   try {
      props.putByteProperty(key, RandomUtil.randomByte());
      props.getBooleanProperty(key);
      Assert.fail();
   } catch (ActiveMQPropertyConversionException e) {
   }

   Assert.assertFalse(props.getBooleanProperty(unknownKey));
}
 
Example #4
Source File: MessageUtil.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public static Object getObjectProperty(final Message message, final String name) {
   final Object val;
   if (MessageUtil.JMSXGROUPID.equals(name)) {
      val = message.getGroupID();
   } else if (MessageUtil.JMSXGROUPSEQ.equals(name)) {
      val = message.getGroupSequence();
   } else if (MessageUtil.JMSXUSERID.equals(name)) {
      val = message.getValidatedUserID();
   } else {
      val = message.getObjectProperty(name);
   }
   if (val instanceof SimpleString) {
      return val.toString();
   }
   return val;
}
 
Example #5
Source File: QueueCommandTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteQueueWithConsumersFailsAndRemoveConsumersTrue() throws Exception {
   SimpleString queueName = new SimpleString("deleteQueue");

   CreateQueue command = new CreateQueue();
   command.setName(queueName.toString());
   command.setFilter("color='green'");
   command.setAutoCreateAddress(true);
   command.setMulticast(true);
   command.setAnycast(false);
   command.execute(new ActionContext());

   server.locateQueue(queueName).addConsumer(new DummyServerConsumer());

   DeleteQueue delete = new DeleteQueue();
   delete.setName(queueName.toString());
   delete.setRemoveConsumers(true);
   delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
   checkExecutionPassed(command);
}
 
Example #6
Source File: MessagePropertyTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void receiveMessages() throws Exception {
   ClientSession session = sf.createSession(true, true);
   session.start();
   try (ClientConsumer consumer = session.createConsumer(ADDRESS)) {
      for (int i = 0; i < numMessages; i++) {
         ClientMessage message = consumer.receive(100);
         assertNotNull("Expecting a message " + i, message);
         assertMessageBody(i, message);
         assertEquals(i, message.getIntProperty("int").intValue());
         assertEquals((short) i, message.getShortProperty("short").shortValue());
         assertEquals((byte) i, message.getByteProperty("byte").byteValue());
         assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001);
         assertEquals(new SimpleString(Integer.toString(i)), message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString()));
         assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]"));

         assertTrue(message.containsProperty("null-value"));
         assertEquals(message.getObjectProperty("null-value"), null);

         message.acknowledge();
      }
      assertNull("no more messages", consumer.receive(50));
   }
   session.commit();
}
 
Example #7
Source File: WildCardRoutingTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testWildcardRoutingStarInMiddle() throws Exception {
   SimpleString addressAB = new SimpleString("a.b.c");
   SimpleString addressAC = new SimpleString("a.c");
   SimpleString address = new SimpleString("*.b.*");
   SimpleString queueName1 = new SimpleString("Q1");
   SimpleString queueName2 = new SimpleString("Q2");
   SimpleString queueName = new SimpleString("Q");
   clientSession.createQueue(new QueueConfiguration(queueName1).setAddress(addressAB).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName2).setAddress(addressAC).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName).setAddress(address).setDurable(false));
   ClientProducer producer = clientSession.createProducer(addressAB);
   ClientProducer producer2 = clientSession.createProducer(addressAC);
   ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
   clientSession.start();
   producer.send(createTextMessage(clientSession, "m1"));
   producer2.send(createTextMessage(clientSession, "m2"));
   ClientMessage m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   Assert.assertEquals("m1", m.getBodyBuffer().readString());
   m.acknowledge();
   m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
}
 
Example #8
Source File: EmbeddedJMSResource.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Get the Queue corresponding to a JMS Destination.
 * <p>
 * The full name of the JMS destination including the prefix should be provided - i.e. queue://myQueue
 * or topic://myTopic.  If the destination type prefix is not included in the destination name, a prefix
 * of "queue://" is assumed.
 *
 * @param destinationName the full name of the JMS Destination
 * @return the number of messages in the JMS Destination
 */
public Queue getDestinationQueue(String destinationName) {
   Queue queue = null;
   ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.TYPE.QUEUE);
   String address = destination.getAddress();
   String name = destination.getName();
   if (destination.isQueue()) {
      queue = jmsServer.getActiveMQServer().locateQueue(destination.getSimpleAddress());
   } else {
      BindingQueryResult bindingQueryResult = null;
      try {
         bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress());
      } catch (Exception ex) {
         log.error(String.format("getDestinationQueue( %s ) - bindingQuery for %s failed", destinationName, destination.getAddress()), ex);
         return null;
      }
      if (bindingQueryResult.isExists()) {
         List<SimpleString> queueNames = bindingQueryResult.getQueueNames();
         if (queueNames.size() > 0) {
            queue = jmsServer.getActiveMQServer().locateQueue(queueNames.get(0));
         }
      }
   }

   return queue;
}
 
Example #9
Source File: ProducerAutoCreateQueueTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testProducerBlockWontGetTimeout() throws Exception {
   Connection connection = null;
   try {
      connection = factory.createConnection("admin", "password");
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue trash = session.createQueue("trash");
      final MessageProducer producer = session.createProducer(trash);
      producer.send(session.createTextMessage("foo"));
      Assert.assertNotNull(server.getPostOffice().getBinding(new SimpleString("trash")));
   } finally {
      if (connection != null) {
         connection.close();
      }
   }
}
 
Example #10
Source File: QueueControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testListScheduledMessagesAsJSON() throws Exception {
   long delay = 2000;
   SimpleString address = RandomUtil.randomSimpleString();
   SimpleString queue = RandomUtil.randomSimpleString();
   int intValue = RandomUtil.randomInt();
   session.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(durable));

   QueueControl queueControl = createManagementControl(address, queue);

   ClientProducer producer = session.createProducer(address);
   ClientMessage message = session.createMessage(false);
   message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
   message.putIntProperty(new SimpleString("key"), intValue);
   producer.send(message);
   // unscheduled message
   producer.send(session.createMessage(durable));

   String jsonString = queueControl.listScheduledMessagesAsJSON();
   Assert.assertNotNull(jsonString);
   JsonArray array = JsonUtil.readJsonArray(jsonString);
   Assert.assertEquals(1, array.size());
   int i = Integer.parseInt(array.getJsonObject(0).get("key").toString().replaceAll("\"", ""));
   Assert.assertEquals(intValue, i);

   Thread.sleep(delay + 500);

   jsonString = queueControl.listScheduledMessagesAsJSON();
   Assert.assertNotNull(jsonString);
   array = JsonUtil.readJsonArray(jsonString);
   Assert.assertEquals(0, array.size());

   consumeMessages(2, session, queue);

   session.deleteQueue(queue);
}
 
Example #11
Source File: WildCardRoutingTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testWildcardRoutingWithHashMultiLengthAddresses() throws Exception {
   SimpleString addressAB = new SimpleString("a.b.c.f");
   SimpleString addressAC = new SimpleString("a.c.f");
   SimpleString address = new SimpleString("a.#.f");
   SimpleString queueName1 = new SimpleString("Q1");
   SimpleString queueName2 = new SimpleString("Q2");
   SimpleString queueName = new SimpleString("Q");
   clientSession.createQueue(new QueueConfiguration(queueName1).setAddress(addressAB).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName2).setAddress(addressAC).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName).setAddress(address).setDurable(false));
   ClientProducer producer = clientSession.createProducer(addressAB);
   ClientProducer producer2 = clientSession.createProducer(addressAC);
   ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
   clientSession.start();
   producer.send(createTextMessage(clientSession, "m1"));
   producer2.send(createTextMessage(clientSession, "m2"));
   ClientMessage m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   Assert.assertEquals("m1", m.getBodyBuffer().readString());
   m.acknowledge();
   m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   Assert.assertEquals("m2", m.getBodyBuffer().readString());
   m.acknowledge();
   m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
}
 
Example #12
Source File: SimpleStringTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testContains() {
   SimpleString simpleString = new SimpleString("abcdefghijklmnopqrst");
   Assert.assertFalse(simpleString.contains('.'));
   Assert.assertFalse(simpleString.contains('%'));
   Assert.assertFalse(simpleString.contains('8'));
   Assert.assertFalse(simpleString.contains('.'));
   Assert.assertTrue(simpleString.contains('a'));
   Assert.assertTrue(simpleString.contains('b'));
   Assert.assertTrue(simpleString.contains('c'));
   Assert.assertTrue(simpleString.contains('d'));
   Assert.assertTrue(simpleString.contains('e'));
   Assert.assertTrue(simpleString.contains('f'));
   Assert.assertTrue(simpleString.contains('g'));
   Assert.assertTrue(simpleString.contains('h'));
   Assert.assertTrue(simpleString.contains('i'));
   Assert.assertTrue(simpleString.contains('j'));
   Assert.assertTrue(simpleString.contains('k'));
   Assert.assertTrue(simpleString.contains('l'));
   Assert.assertTrue(simpleString.contains('m'));
   Assert.assertTrue(simpleString.contains('n'));
   Assert.assertTrue(simpleString.contains('o'));
   Assert.assertTrue(simpleString.contains('p'));
   Assert.assertTrue(simpleString.contains('q'));
   Assert.assertTrue(simpleString.contains('r'));
   Assert.assertTrue(simpleString.contains('s'));
   Assert.assertTrue(simpleString.contains('t'));
}
 
Example #13
Source File: BindingsImplTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
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()));
      }
   }
}
 
Example #14
Source File: DeadLetterAddressTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasicSendToMultipleQueues() throws Exception {
   SimpleString dla = new SimpleString("DLA");
   SimpleString qName = new SimpleString("q1");
   AddressSettings addressSettings = new AddressSettings().setMaxDeliveryAttempts(1).setDeadLetterAddress(dla);
   server.getAddressSettingsRepository().addMatch(qName.toString(), addressSettings);
   SimpleString dlq = new SimpleString("DLQ1");
   SimpleString dlq2 = new SimpleString("DLQ2");
   clientSession.createQueue(new QueueConfiguration(dlq).setAddress(dla).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(dlq2).setAddress(dla).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(qName).setDurable(false));
   ClientProducer producer = clientSession.createProducer(qName);
   producer.send(createTextMessage(clientSession, "heyho!"));
   clientSession.start();
   ClientConsumer clientConsumer = clientSession.createConsumer(qName);
   ClientMessage m = clientConsumer.receive(500);
   m.acknowledge();
   Assert.assertNotNull(m);
   Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
   // force a cancel
   clientSession.rollback();
   m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
   clientConsumer.close();
   clientConsumer = clientSession.createConsumer(dlq);
   m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   m.acknowledge();
   Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
   clientConsumer.close();
   clientConsumer = clientSession.createConsumer(dlq2);
   m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   m.acknowledge();
   Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
   clientConsumer.close();
}
 
Example #15
Source File: AMQPSessionCallbackTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Test that the AMQPSessionCallback grants no credit when the computation results in negative credit
 */
@Test
public void testOfferProducerWithAddressDoesNotGrantNegativeCredit() throws Exception {
   // Mock returns to get at the runnable that grants credit.
   Mockito.when(manager.getServer()).thenReturn(server);
   Mockito.when(server.getPagingManager()).thenReturn(pagingManager);
   Mockito.when(pagingManager.getPageStore(any(SimpleString.class))).thenReturn(pagingStore);

   // Capture credit runnable and invoke to trigger credit top off
   ArgumentCaptor<Runnable> argument = ArgumentCaptor.forClass(Runnable.class);
   AMQPSessionCallback session = new AMQPSessionCallback(protonSPI, manager, connection, transportConnection, executor, operationContext);

   // Credit is at threshold
   Mockito.when(receiver.getCredit()).thenReturn(AMQP_LOW_CREDITS_DEFAULT);

   session.flow(new SimpleString("test"), ProtonServerReceiverContext.createCreditRunnable(1, AMQP_LOW_CREDITS_DEFAULT, receiver, connection));

   // Run the credit refill code.
   Mockito.verify(pagingStore).checkMemory(argument.capture());
   assertNotNull(argument.getValue());
   argument.getValue().run();

   // Ensure we aren't looking at remote credit as that gives us the wrong view of what credit is at the broker
   Mockito.verify(receiver, never()).getRemoteCredit();

   // Credit runnable should not grant what would be negative credit here
   Mockito.verify(receiver, never()).flow(anyInt());
}
 
Example #16
Source File: AbstractFederationStream.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public AbstractFederationStream(final ActiveMQServer server, final Federation federation, final String name, final FederationStreamConfiguration config,
                                final FederationConnection connection) {
   this.server = server;
   this.federation = federation;
   Objects.requireNonNull(config.getName());
   this.name = SimpleString.toSimpleString(config.getName());
   this.config = config;
   this.connection = connection != null ? connection : new FederationConnection(server.getConfiguration(), name, config.getConnectionConfiguration());
}
 
Example #17
Source File: BridgeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testInjectedTransformer() throws Exception {
   final SimpleString ADDRESS = new SimpleString("myAddress");
   final SimpleString QUEUE = new SimpleString("myQueue");
   final String BRIDGE = "myBridge";

   ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl();
   Transformer transformer = new Transformer() {
      @Override
      public Message transform(Message message) {
         return null;
      }
   };

   serviceRegistry.addBridgeTransformer(BRIDGE, transformer);
   Configuration config = createDefaultInVMConfig().addConnectorConfiguration("in-vm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
   ActiveMQServer server = addServer(new ActiveMQServerImpl(config, null, null, null, serviceRegistry));
   server.start();
   server.waitForActivation(100, TimeUnit.MILLISECONDS);
   server.createQueue(new QueueConfiguration(QUEUE).setAddress(ADDRESS).setRoutingType(RoutingType.ANYCAST).setDurable(false));
   List<String> connectors = new ArrayList<>();
   connectors.add("in-vm");
   server.deployBridge(new BridgeConfiguration().setName(BRIDGE).setQueueName(QUEUE.toString()).setForwardingAddress(ADDRESS.toString()).setStaticConnectors(connectors));
   Bridge bridge = server.getClusterManager().getBridges().get(BRIDGE);
   assertNotNull(bridge);
   assertEquals(transformer, ((BridgeImpl) bridge).getTransformer());
}
 
Example #18
Source File: ClientSessionImpl.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
 *
 * @param address      the queue will be bound to this address
 * @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
 * @param queueName    the name of the queue
 * @throws ActiveMQException in an exception occurs while creating the queue
 */
@Deprecated
@Override
public void createQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException {
   internalCreateQueue(SimpleString.toSimpleString(address),
                       SimpleString.toSimpleString(queueName),
                       false,
                       false,
                       new QueueAttributes()
                               .setRoutingType(routingType)
                               .setFilterString(null)
                               .setDurable(false)
                               .setPurgeOnNoConsumers(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers())
                               .setMaxConsumers(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers()));
}
 
Example #19
Source File: ExpiryAddressTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasicSend() throws Exception {
   SimpleString ea = new SimpleString("EA");
   SimpleString adSend = new SimpleString("a1");
   SimpleString qName = new SimpleString("q1");
   SimpleString eq = new SimpleString("EA1");
   AddressSettings addressSettings = new AddressSettings().setExpiryAddress(ea);
   server.getAddressSettingsRepository().addMatch("#", addressSettings);
   clientSession.createQueue(new QueueConfiguration(eq).setAddress(ea).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(qName).setAddress(adSend).setDurable(false));

   ClientProducer producer = clientSession.createProducer(adSend);
   ClientMessage clientMessage = createTextMessage(clientSession, "heyho!");
   clientMessage.setExpiration(System.currentTimeMillis());
   producer.send(clientMessage);

   clientSession.start();
   ClientConsumer clientConsumer = clientSession.createConsumer(qName);
   ClientMessage m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
   m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
   clientConsumer.close();
   clientConsumer = clientSession.createConsumer(eq);
   m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   Assert.assertEquals(qName.toString(), m.getStringProperty(Message.HDR_ORIGINAL_QUEUE));
   Assert.assertEquals(adSend.toString(), m.getStringProperty(Message.HDR_ORIGINAL_ADDRESS));
   Assert.assertNotNull(m);
   Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
   m.acknowledge();
}
 
Example #20
Source File: SimpleStringTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testEquals() throws Exception {
   Assert.assertFalse(new SimpleString("abcdef").equals(new Object()));

   Assert.assertFalse(new SimpleString("abcef").equals(null));

   Assert.assertEquals(new SimpleString("abcdef"), new SimpleString("abcdef"));

   Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("abggcdef")));
   Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("ghijkl")));
}
 
Example #21
Source File: SendAckFailTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void storeDuplicateIDTransactional(long txID,
                                          SimpleString address,
                                          byte[] duplID,
                                          long recordID) throws Exception {
   manager.storeDuplicateIDTransactional(txID, address, duplID, recordID);
}
 
Example #22
Source File: ActiveMQMapMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public short getShort(final String name) throws JMSException {
   try {
      return map.getShortProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException e) {
      throw new MessageFormatException(e.getMessage());
   }
}
 
Example #23
Source File: ServerJMSMapMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public boolean getBoolean(final String name) throws JMSException {
   try {
      return map.getBooleanProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException e) {
      throw new MessageFormatException(e.getMessage());
   }
}
 
Example #24
Source File: MessageHeaderTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
                                     final SimpleString filterString,
                                     final int windowSize,
                                     final int maxRate,
                                     final boolean browseOnly) throws ActiveMQException {
   return null;
}
 
Example #25
Source File: ActiveMQServerImpl.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Deprecated
@Override
public Queue createQueue(final SimpleString address,
                         final RoutingType routingType,
                         final SimpleString queueName,
                         final SimpleString filter,
                         final boolean durable,
                         final boolean temporary,
                         final int maxConsumers,
                         final boolean purgeOnNoConsumers,
                         final boolean autoCreateAddress) throws Exception {
   return createQueue(address, routingType, queueName, filter, null, durable, temporary, false, maxConsumers, purgeOnNoConsumers, autoCreateAddress);
}
 
Example #26
Source File: BackupRecoveryJournalLoader.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void postLoad(Journal messageJournal,
                     ResourceManager resourceManager,
                     Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap) throws Exception {
   ScaleDownHandler scaleDownHandler = new ScaleDownHandler(pagingManager, postOffice, nodeManager, clusterController, parentServer != null ? parentServer.getStorageManager() : storageManager);
   locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator, storageManager));

   try (ClientSessionFactory sessionFactory = locator.createSessionFactory()) {
      scaleDownHandler.scaleDown(sessionFactory, resourceManager, duplicateIDMap, parentServer != null ? parentServer.getConfiguration().getManagementAddress() : configuration.getManagementAddress(), parentServer != null ? parentServer.getNodeID() : null);
   }
}
 
Example #27
Source File: PersistedRoles.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getEncodeSize() {
   return addressMatch.sizeof() + SimpleString.sizeofNullableString(sendRoles) +
      SimpleString.sizeofNullableString(consumeRoles) +
      SimpleString.sizeofNullableString(createDurableQueueRoles) +
      SimpleString.sizeofNullableString(deleteDurableQueueRoles) +
      SimpleString.sizeofNullableString(createNonDurableQueueRoles) +
      SimpleString.sizeofNullableString(deleteNonDurableQueueRoles) +
      SimpleString.sizeofNullableString(manageRoles) +
      SimpleString.sizeofNullableString(browseRoles) +
      SimpleString.sizeofNullableString(createAddressRoles) +
      SimpleString.sizeofNullableString(deleteAddressRoles);
}
 
Example #28
Source File: ReplicationSyncFileMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public ReplicationSyncFileMessage(AbstractJournalStorageManager.JournalContent content,
                                  SimpleString storeName,
                                  long id,
                                  int size,
                                  ByteBuf buffer) {
   this();
   this.byteBuffer = buffer;
   this.pageStoreName = storeName;
   this.dataSize = size;
   this.fileId = id;
   this.journalType = content;
   determineType();
}
 
Example #29
Source File: QueueControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetScheduledCount() throws Exception {
   long delay = 500;
   SimpleString address = RandomUtil.randomSimpleString();
   SimpleString queue = RandomUtil.randomSimpleString();

   session.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(durable));

   QueueControl queueControl = createManagementControl(address, queue);
   Assert.assertEquals(0, queueControl.getScheduledCount());

   ClientProducer producer = session.createProducer(address);
   ClientMessage message = session.createMessage(durable);
   message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
   producer.send(message);

   long timeout = System.currentTimeMillis() + 5000;
   while (timeout > System.currentTimeMillis() && queueControl.getScheduledCount() != 1) {
      Thread.sleep(100);
   }

   assertScheduledMetrics(queueControl, 1, durable);
   assertMessageMetrics(queueControl, 1, durable);

   consumeMessages(0, session, queue);

   Thread.sleep(delay * 2);

   Assert.assertEquals(0, queueControl.getScheduledCount());
   consumeMessages(1, session, queue);
   assertMessageMetrics(queueControl, 0, durable);
   assertScheduledMetrics(queueControl, 0, durable);

   session.deleteQueue(queue);
}
 
Example #30
Source File: OpenWireMessageConverter.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private static void putMsgCluster(final BrokerId[] cluster, final CoreMessage coreMessage) {
   final StringBuilder builder = new StringBuilder();
   for (int i = 0, size = cluster.length; i < size; i++) {
      builder.append(cluster[i].getValue());
      if (i != (size - 1)) {
         builder.append(','); //is this separator safe?
      }
   }
   coreMessage.putStringProperty(AMQ_MSG_CLUSTER, new SimpleString(builder.toString()));
}