• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iluwatar / java-design-patterns / #1673

06 Sep 2015 05:33PM UTC coverage: 84.947% (-0.7%) from 85.644%
#1673

push

Markus
Removed the Markdown Plus custom heading id's

Because the renderer of github doesnt support markdown plus...

3070 of 3614 relevant lines covered (84.95%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.53
/poison-pill/src/main/java/com/iluwatar/poison/pill/Consumer.java
1
package com.iluwatar.poison.pill;
2

3
import com.iluwatar.poison.pill.Message.Headers;
4

5
/**
6
 * Class responsible for receiving and handling submitted to the queue messages
7
 */
8
public class Consumer {
9

10
        private final MQSubscribePoint queue;
11
        private final String name;
12

13
        public Consumer(String name, MQSubscribePoint queue) {
1✔
14
                this.name = name;
1✔
15
                this.queue = queue;
1✔
16
        }
1✔
17

18
        public void consume() {
19
                while (true) {
20
                        Message msg;
21
                        try {
22
                                msg = queue.take();
×
23
                                if (msg == Message.POISON_PILL) {
×
24
                                        System.out.println(String.format("Consumer %s receive request to terminate.", name));
×
25
                                        break;
×
26
                                }
27
                        } catch (InterruptedException e) {
×
28
                                // allow thread to exit
29
                                System.err.println(e);
×
30
                                return;
×
31
                        }
×
32

33
                        String sender = msg.getHeader(Headers.SENDER);
×
34
                        String body = msg.getBody();
×
35
                        System.out.println(String.format("Message [%s] from [%s] received by [%s]", body, sender, name));
×
36
                }
×
37
        }
×
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc