Merge PR #112
This commit is contained in:
commit
3233371483
|
@ -37,6 +37,13 @@ import org.apache.activemq.common.example.ActiveMQExample;
|
|||
*/
|
||||
public class ReplicatedTransactionFailoverExample extends ActiveMQExample
|
||||
{
|
||||
|
||||
// You need to guarantee uniqueIDs when using duplicate detection
|
||||
// It needs to be unique even after a restart
|
||||
// as these IDs are stored on the journal for control
|
||||
// We recommend some sort of UUID, but for this example the Current Time as string would be enough
|
||||
String uniqueID = Long.toString(System.currentTimeMillis());
|
||||
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
new ReplicatedTransactionFailoverExample().run(args);
|
||||
|
@ -146,7 +153,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
|
|||
// We set the duplicate detection header - so the server will ignore the same message
|
||||
// if sent again after failover
|
||||
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "uniqueid" + i);
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i);
|
||||
|
||||
producer.send(message);
|
||||
|
||||
|
@ -169,7 +176,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample
|
|||
// We set the duplicate detection header - so the server will ignore the same message
|
||||
// if sent again after failover
|
||||
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "uniqueid" + i);
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i);
|
||||
|
||||
producer.send(message);
|
||||
|
||||
|
|
|
@ -37,11 +37,19 @@ import org.apache.activemq.common.example.ActiveMQExample;
|
|||
*/
|
||||
public class TransactionFailoverExample extends ActiveMQExample
|
||||
{
|
||||
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
new TransactionFailoverExample().run(args);
|
||||
}
|
||||
|
||||
// You need to guarantee uniqueIDs when using duplicate detection
|
||||
// It needs to be unique even after a restart
|
||||
// as these IDs are stored on the journal for control
|
||||
// We recommend some sort of UUID, but for this example the Current Time as string would be enough
|
||||
String uniqueID = Long.toString(System.currentTimeMillis());
|
||||
|
||||
|
||||
@Override
|
||||
public boolean runExample() throws Exception
|
||||
{
|
||||
|
@ -138,15 +146,13 @@ public class TransactionFailoverExample extends ActiveMQExample
|
|||
final int numMessages,
|
||||
final boolean killServer) throws Exception
|
||||
{
|
||||
|
||||
// We send half of messages
|
||||
for (int i = 0; i < numMessages / 2; i++)
|
||||
{
|
||||
TextMessage message = session.createTextMessage("This is text message " + i);
|
||||
|
||||
// We set the duplicate detection header - so the server will ignore the same message
|
||||
// if sent again after failover
|
||||
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "uniqueid" + i);
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i);
|
||||
|
||||
producer.send(message);
|
||||
|
||||
|
@ -169,7 +175,7 @@ public class TransactionFailoverExample extends ActiveMQExample
|
|||
// We set the duplicate detection header - so the server will ignore the same message
|
||||
// if sent again after failover
|
||||
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "uniqueid" + i);
|
||||
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i);
|
||||
|
||||
producer.send(message);
|
||||
|
||||
|
|
Loading…
Reference in New Issue