Reformat rest of the design patterns - Issue #224

This commit is contained in:
Ankur Kaushal
2015-11-01 21:29:13 -05:00
parent 449340bd2b
commit 306b1f3d31
337 changed files with 6744 additions and 6851 deletions
@@ -7,32 +7,33 @@ import com.iluwatar.poison.pill.Message.Headers;
*/
public class Consumer {
private final MQSubscribePoint queue;
private final String name;
private final MQSubscribePoint queue;
private final String name;
public Consumer(String name, MQSubscribePoint queue) {
this.name = name;
this.queue = queue;
}
public Consumer(String name, MQSubscribePoint queue) {
this.name = name;
this.queue = queue;
}
public void consume() {
while (true) {
Message msg;
try {
msg = queue.take();
if (msg == Message.POISON_PILL) {
System.out.println(String.format("Consumer %s receive request to terminate.", name));
break;
}
} catch (InterruptedException e) {
// allow thread to exit
System.err.println(e);
return;
}
public void consume() {
while (true) {
Message msg;
try {
msg = queue.take();
if (msg == Message.POISON_PILL) {
System.out.println(String.format("Consumer %s receive request to terminate.", name));
break;
}
} catch (InterruptedException e) {
// allow thread to exit
System.err.println(e);
return;
}
String sender = msg.getHeader(Headers.SENDER);
String body = msg.getBody();
System.out.println(String.format("Message [%s] from [%s] received by [%s]", body, sender, name));
}
}
String sender = msg.getHeader(Headers.SENDER);
String body = msg.getBody();
System.out.println(String.format("Message [%s] from [%s] received by [%s]", body, sender,
name));
}
}
}