Skip to content

Fix #309: make channelName available in Postprocessor script - #395

Open
ggiannola wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
ggiannola:fix/309-postprocessor-channelname
Open

Fix #309: make channelName available in Postprocessor script#395
ggiannola wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
ggiannola:fix/309-postprocessor-channelname

Conversation

@ggiannola

@ggiannola ggiannola commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Fixes #309. The channelName variable was not available in Postprocessor scripts, even though it is available in Deploy, Undeploy, and Preprocessor scripts.

Root cause

The Postprocessor scope (JavaScriptScopeUtil.getPostprocessorScope) derives channelName from message.getMergedConnectorMessage().getChannelName().

However, Message.getMergedConnectorMessage() built the merged ConnectorMessage setting channelId, messageId, serverId, and receivedDate — but never channelName. The value therefore resolved to null in Postprocessor scripts.

This also explains why the other script contexts were unaffected: they receive the channel name directly (Deploy/Undeploy via getDeployScope/getUndeployScope, Preprocessor from the connector message) rather than through the merged connector message.

Fix

In Message.getMergedConnectorMessage(), populate channelName on the merged connector message:

  • from the Message's own channelName field, and
  • falling back to the source connector message's channelName, which is reliably set during processing (see the ConnectorMessage construction in Channel).

The fallback matters because the Message created during processing does not always carry channelName, while the source connector message does.

Tests

Added MessageTest covering three cases:

  1. The merged message inherits channelName from the source connector message.
  2. The merged message uses the Message-level channelName when set.
  3. channelName stays null when unavailable, so the fix does not fabricate a value.

Verified with ./gradlew :donkey:test: 21 tests pass, 0 failures (MessageTest 3, StatisticsTest 9, JdbcDaoTest 8, ChannelTest 1).

…essor script

The Postprocessor scope derives channelName from
message.getMergedConnectorMessage().getChannelName(), but
Message.getMergedConnectorMessage() never populated channelName on the
merged ConnectorMessage. As a result the channelName variable was null
in Postprocessor scripts, even though it is available in Deploy,
Undeploy, and Preprocessor scripts.

Populate channelName on the merged connector message from the Message's
own channelName, falling back to the source connector message's
channelName (which is reliably set during processing).

Adds MessageTest covering the three cases.

Signed-off-by: Giovanni Giannola <[email protected]>
New files in this project use SPDX headers attributing copyright to the
contributor, rather than the legacy Mirth Corporation header carried by
pre-fork files.

Signed-off-by: Giovanni Giannola <[email protected]>
@ggiannola
ggiannola force-pushed the fix/309-postprocessor-channelname branch from cfe7bcb to 0de1890 Compare July 29, 2026 18:14
@pacmano1

pacmano1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@ggiannola, this works in the post processor.

logger.info(ChannelUtil.getChannelName(channelId))

Not that your PR is "wrong", but based on this trivial workaround it seems unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] channelName variable is not available in Postprocessor script

2 participants