mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Handle both single and multi part payloads in splitter/merger/proxy
This commit is contained in:
@@ -18,7 +18,10 @@
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProxy.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQProxy::FairMQProxy()
|
||||
: fMultipart(1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,22 +31,109 @@ FairMQProxy::~FairMQProxy()
|
||||
|
||||
void FairMQProxy::Run()
|
||||
{
|
||||
while (CheckCurrentState(RUNNING))
|
||||
if (fMultipart)
|
||||
{
|
||||
FairMQParts parts;
|
||||
|
||||
if (Receive(parts, "data-in") >= 0)
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
if (Send(parts, "data-out") < 0)
|
||||
FairMQParts payload;
|
||||
if (Receive(payload, "data-in") >= 0)
|
||||
{
|
||||
if (Send(payload, "data-out") < 0)
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
unique_ptr<FairMQMessage> payload(fTransportFactory->CreateMessage());
|
||||
if (Receive(payload, "data-in") >= 0)
|
||||
{
|
||||
if (Send(payload, "data-out") < 0)
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProxy::SetProperty(const int key, const string& value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string FairMQProxy::GetProperty(const int key, const string& default_ /*= ""*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProxy::SetProperty(const int key, const int value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Multipart:
|
||||
fMultipart = value;
|
||||
break;
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int FairMQProxy::GetProperty(const int key, const int default_ /*= 0*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Multipart:
|
||||
return fMultipart;
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
||||
string FairMQProxy::GetPropertyDescription(const int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Multipart:
|
||||
return "Multipart: Handle payloads as multipart messages.";
|
||||
default:
|
||||
return FairMQDevice::GetPropertyDescription(key);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProxy::ListProperties()
|
||||
{
|
||||
LOG(INFO) << "Properties of FairMQProxy:";
|
||||
for (int p = FairMQConfigurable::Last; p < FairMQProxy::Last; ++p)
|
||||
{
|
||||
LOG(INFO) << " " << GetPropertyDescription(p);
|
||||
}
|
||||
LOG(INFO) << "---------------------------";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user