@Override
public Task<?> invoke(final RemoteReference toReference, final Method m, final boolean oneWay, final int methodId, final Object[] params)
{
if (state == NodeCapabilities.NodeState.STOPPED)
{
throw new IllegalStateException("Stage is stopped. " + this.toString());
}
final Invocation invocation = new Invocation(toReference, m, oneWay, methodId, params, null);
final ActorTaskContext context = ActorTaskContext.current();
if (context != null)
{
Map<String, Object> headers = null;
for (final String key : stickyHeaders)
{
final Object value = context.getProperty(key);
if (value != null)
{
if (headers == null)
{
headers = new HashMap<>();
}
headers.put(key, value);
}
}
invocation.setHeaders(headers);
}
final Task<Void> result = pipeline.write(invocation);
return result;
}