/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
protected CoreMessage(CoreMessage other, TypedProperties copyProperties) { this.body = other.body; this.endOfBodyPosition = other.endOfBodyPosition; this.messageID = other.messageID; this.address = other.address; this.type = other.type; this.durable = other.durable; this.expiration = other.expiration; this.timestamp = other.timestamp; this.priority = other.priority; this.userID = other.userID; this.coreMessageObjectPools = other.coreMessageObjectPools; if (copyProperties != null) { this.properties = new TypedProperties(copyProperties); } if (other.buffer != null) { this.buffer = other.buffer.copy(); } }
/** * I am keeping this synchronized as the decode of the Properties is lazy */ protected TypedProperties checkProperties() { if (properties == null) { TypedProperties properties = new TypedProperties(); if (buffer != null && propertiesLocation >= 0) { final ByteBuf byteBuf = buffer.duplicate().readerIndex(propertiesLocation); properties.decode(byteBuf, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } this.properties = properties; } return this.properties; }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
@Override public synchronized void start() throws Exception { if (started) { return; } endpoint.openClient(); started = true; thread = new Thread(new DiscoveryRunnable(), "activemq-discovery-group-thread-" + name); thread.setDaemon(true); thread.start(); if (notificationService != null) { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name)); Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STARTED, props); notificationService.sendNotification(notification); } }
TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name)); Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STOPPED, props);
public TypedProperties createExtraProperties() { if (extraProperties == null) { extraProperties = new TypedProperties(); } return extraProperties; }
/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
public AMQPMessage(long messageFormat, ReadableBuffer data, TypedProperties extraProperties, CoreMessageObjectPools coreMessageObjectPools) { this.data = data; this.messageFormat = messageFormat; this.bufferValid = true; this.coreMessageObjectPools = coreMessageObjectPools; this.extraProperties = extraProperties == null ? null : new TypedProperties(extraProperties); parseHeaders(); }
/** * Utility method to set the map on a message body */ public static TypedProperties readBodyMap(ActiveMQBuffer message) { TypedProperties map = new TypedProperties(); readBodyMap(message, map); return map; }
@Before public void setUp() throws Exception { props = new TypedProperties(); key = RandomUtil.randomSimpleString(); }
private Notification createProposalNotification(SimpleString groupId, SimpleString clusterName) { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, groupId); props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, clusterName); props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address); props.putIntProperty(ManagementHelper.HDR_DISTANCE, 0); return new Notification(null, CoreNotificationType.PROPOSAL, props); }
@Test public void testEmptyTypedProperties() throws Exception { Assert.assertEquals(0, props.getPropertyNames().size()); props.putTypedProperties(new TypedProperties()); Assert.assertEquals(0, props.getPropertyNames().size()); }
@Test public void testEncodedSizeAfterClearIsSameAsNewTypedProperties() throws Exception { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(SimpleString.toSimpleString("helllllloooooo"), SimpleString.toSimpleString("raaaaaaaaaaaaaaaaaaaaaaaa")); props.clear(); assertEquals(new TypedProperties().getEncodeSize(), props.getEncodeSize()); }
@Override public void sendProposalResponse(final Response response, final int distance) throws Exception { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, response.getGroupId()); props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, response.getClusterName()); props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE, response.getAlternativeClusterName()); props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address); props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance); Notification notification = new Notification(null, CoreNotificationType.PROPOSAL_RESPONSE, props); managementService.sendNotification(notification); }
@Test public void testClearInternalPropertiesIfAny() { TypedProperties properties = new TypedProperties(PROP_NAME::equals); properties.putBooleanProperty(PROP_NAME, RandomUtil.randomBoolean()); Assert.assertTrue(properties.clearInternalProperties()); Assert.assertFalse(properties.containsProperty(PROP_NAME)); }
@Test public void testCopyContructor() throws Exception { props.putSimpleStringProperty(key, RandomUtil.randomSimpleString()); TypedProperties copy = new TypedProperties(props); Assert.assertEquals(props.getEncodeSize(), copy.getEncodeSize()); Assert.assertEquals(props.getPropertyNames(), copy.getPropertyNames()); Assert.assertTrue(copy.containsProperty(key)); Assert.assertEquals(props.getProperty(key), copy.getProperty(key)); }