Repository navigation
Added support for multiple partnerships with matching as2 ids - #632
Conversation
uhurusurfa
left a comment
There was a problem hiding this comment.
Can you provide some background as to why you want to be able to have different configurations for sending?
| // config.xml are excluded since their "name" is only the defaults string or "generic" | ||
| if (PARTNERSHIP_POLLER.equals(configSource) && partnershipName != null && moduleNode instanceof Element) { | ||
| ((Element) moduleNode).setAttribute(MessageBuilderModule.PARAM_PARTNERSHIP_NAME, partnershipName); | ||
| } |
There was a problem hiding this comment.
I would prefer not to directly manipulate XML to make this work.
Instead, I suggest you support setting the partnership name via the defaults attribute.
The attribute would be set up like this within the specific partnership(s) you want to duplicate AS2 ID's:
<pollerConfig enabled="true" defaults="name=MyCompany-to-PartnerA"/>
... or change the global poller default in config.xml if that is what you want for all sending partnerships.
To support this, modify the MessageParameters.setParameter method to something like this:
public void setParameter(String key, String value) throws InvalidParameterException {
StringTokenizer keyParts = new StringTokenizer(key, ".", false);
if (keyParts.countTokens() == 1) {
String partnershipName = keyParts.nextToken();
if ("name".equals(key)) {
getTarget().getPartnership().setName(key);
} else {
throw new InvalidParameterException("Unsupported key identifier", this, key, null);
}
}
if (keyParts.countTokens() != 2) {
throw new InvalidParameterException("Invalid key format", this, key, null);
}
String area = keyParts.nextToken();
String areaID = keyParts.nextToken();
if (area.equals(KEY_SENDER)) {
getTarget().getPartnership().setSenderID(areaID, value);
} else if (area.equals(KEY_RECEIVER)) {
getTarget().getPartnership().setReceiverID(areaID, value);
} else if (area.equals(KEY_ATTRIBUTES)) {
getTarget().setAttribute(areaID, value);
} else if (area.equals(KEY_HEADERS)) {
getTarget().setHeader(areaID, value);
} else {
throw new InvalidParameterException("Invalid area in key", this, key, null);
}
}
There was a problem hiding this comment.
We have a remote partner who relies on different subjects for different message types, while still using the same AS2 Ids for both scenarios. In our previous software, we could override things like the subject depending on how we triggered a message to be sent. I saw this might be possible with filename/regex parsing, but that solution didn't seem feasible for a few reasons.
My solution is to allow multiple partnerships with the same AS2 Ids while other configurations, like the subject, can differ. I don't think this should cause any problems since partnership names are forced to be unique anyway, and this should allow for more configuration flexibility.
I made the change to the approach you mentioned and updated the base config.xml to include name=$partnership.name$ since the doc recommends not touching the defaults.
There was a problem hiding this comment.
If the different message types could be inferred from the file name then there are 2 possibilities:
- Enhance the file name parser so that you have access to the message subject. It sounds like you investigated that so I am assuming there are significant issues with that route.
- Add support for a special workflow to be invoked as part of the message building process.
There is also the possibility of supporting multiple directories for the same directory poller that avoids havng to duplicate the partnership.
If you think that you would like a more dynamic solution please feel free to start a discussion and we can see if there might be a way to make it work for you.
There was a problem hiding this comment.
I don't believe our filenames are consistent enough for option 1. I did briefly consider something like having multiple pollers/directories on the one partnership, where the poller itself could override some of these attributes, but that seemed kind of clunky to me.
I landed on this solution partially because it feels more intuitive to me for a partnership to have a single outbox, and for a poller to be directly attached to the partnership it is defined on, rather than by matching AS2 IDs. Also, the separate configuration/subject serves a separate business purpose, but we just happen to reuse the AS2 IDs, so having them as a separate partnership makes sense to me in that regard.
I'm confident this will work perfectly for us, but if you have any suggestions on a better/more generic solution, I'd be happy to look into it.
Thanks for the help and insight on this!
uhurusurfa
left a comment
There was a problem hiding this comment.
👍 thanks for the enhancement.
No description provided.