1
2
3
4
5
6
7
8
9
10
11 package org.mule.lifecycle.processor;
12
13 import org.mule.api.MessagingException;
14 import org.mule.api.MuleEvent;
15 import org.mule.api.MuleException;
16 import org.mule.api.lifecycle.LifecycleState;
17 import org.mule.api.lifecycle.Startable;
18 import org.mule.config.i18n.CoreMessages;
19
20 public class ProcessIfStartedWaitIfSyncPausedMessageProcessor extends
21 ProcessIfStartedWaitIfPausedMessageProcessor
22 {
23
24 public ProcessIfStartedWaitIfSyncPausedMessageProcessor(Startable startable, LifecycleState lifecycleState)
25 {
26 super(startable, lifecycleState);
27 }
28
29
30
31 @Override
32 public MuleEvent process(MuleEvent event) throws MuleException
33 {
34 if (accept(event))
35 {
36 if (isPaused() && event.getExchangePattern().hasResponse())
37 {
38 try
39 {
40 if (logger.isDebugEnabled())
41 {
42 logger.debug(startable.getClass().getName() + " " + getStartableName(startable)
43 + " is paused. Blocking call until resumd");
44 }
45 while (isPaused())
46 {
47 Thread.sleep(500);
48 }
49 }
50 catch (InterruptedException e)
51 {
52 throw new MessagingException(
53 CoreMessages.interruptedWaitingForPaused(getStartableName(startable)), event, e);
54 }
55 }
56 return processNext(event);
57 }
58 else
59 {
60 return handleUnaccepted(event);
61 }
62 }
63 }