public static class FeedThread extends Thread {
public boolean running = true;
public void run() {
MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
String clientID = UUIDUtils.createUUID();
Random random = new Random();
double initialValue = 35;
double currentValue = 35;
double maxChange = initialValue * 0.005;
while (running) {
double change = maxChange - random.nextDouble() * maxChange * 2;
double newValue = currentValue + change;
if (currentValue < initialValue + initialValue * 0.15
&& currentValue > initialValue - initialValue * 0.15) {
currentValue = newValue;
} else {
currentValue -= change;
}
AsyncMessage msg = new AsyncMessage();
msg.setDestination("feed");
msg.setClientId(clientID);
msg.setMessageId(UUIDUtils.createUUID());
msg.setTimestamp(System.currentTimeMillis());
msg.setBody(new Double(currentValue));
msgBroker.routeMessageToService(msg, null);
System.out.println("" + currentValue);
try {
Thread.sleep(300);