# Can Signal trigger Activity and keep strict order?

**URL:** <https://community.temporal.io/t/can-signal-trigger-activity-and-keep-strict-order/1060>\
**Category:** Community Support\
**Created:** [November 21, 2020, 11:35pm UTC](https://community.temporal.io/t/can-signal-trigger-activity-and-keep-strict-order/1060 "2020-11-21T23:35:36Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [November 22, 2020, 1:24am UTC](https://community.temporal.io/t/can-signal-trigger-activity-and-keep-strict-order/1060/4 "2020-11-22T01:24:43Z")

</div>

Yes, it is conceptually possible to have something like @OneByOneSignalMethod. But the whole thing can be implemented in a few lines of code it is not really needed.

Here is an example that doesn’t even need a blocking queue:

```java
  public static class GreetingWorkflowImpl implements GreetingWorkflow {

    private final Queue<String> messageQueue = new ArrayDeque<>();
    private boolean exit = false;

    @Override
    public void getGreetings() {
      List<String> receivedMessages = new ArrayList<>(10);

      while (true) {
        Workflow.await(() -> !messageQueue.isEmpty() || exit);
        if (messageQueue.isEmpty() && exit) {
          break;
        }
        String message = messageQueue.poll();
        // process message 
        ...
      }
    }

    @Override
    public void waitForName(String name) {
      messageQueue.add("Hello " + name + "!");
    }

    @Override
    public void exit() {
      exit = true;
    }
  }

```

The whole sample is [here](https://github.com/darewreck54/temporal-java-samples/blob/cd68261f5837aded1e30437af56db0891712b7cf/src/main/java/io/temporal/samples/hello/HelloSignal.java).

---

_[View the full topic](https://community.temporal.io/t/can-signal-trigger-activity-and-keep-strict-order/1060)._
