---
schema_version: "1"
id: 079463bb4ebdbcb2ed7e0b21e1f6e87f734d6fb574c81a0378761fcd14d71d87
title: Anypoint MQ Publish Operation
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-mq-connector/2.x/anypoint-mq-publish.md
canonical_url: https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-publish
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 53962e8713d7053ced4960d642d081c1164c2d51c34aad26ba324fc35f60e17d
description: MuleSoft Documentation Site
release: 2.x
latest: false
---
---
product: Anypoint MQ Connector
version: 2.x
---

# Anypoint MQ Publish Operation

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The Publish operation in the Anypoint MQ connector lets you create a new Anypoint MQ message and
send it to the specified destination, be it a queue, FIFO queue, or a message exchange. With it, you
can configure not only the content of the message, but also all the headers and properties you need.

## Send a Message

When used in its default form, the connector publishes whatever is in its message payload:

```xml
<anypoint-mq:publish destination="invoiceQueue" config-ref="MQ_config"/>
```

But what happens if the payload is not in the correct format, and you actually need to make a
transformation? You can place a DataWeave transformation before the `publish` operation, but that
would cause the message payload to change and impact the operation placed after the `publish`
operation.

To avoid this undesired impact, you can now place the transformation inside the `publish` operation:

```xml
<anypoint-mq:publish destination="invoiceQueue" config-ref="MQ_config">
  <anypoint-mq:body>#[%dw 2.0
   output application/json
   ---
   payload.payments
   ]</anypoint-mq:body>
</anypoint-mq:publish>
```

The transformation can be used for generating the content that is published, without producing a
side effect on the message in transit.

## Configure User Properties

Every Anypoint MQ message can have a set of properties, which can be used in many different ways,
such as to provide compatibility with other messaging systems or to communicate the content-type of
a message. The `publish` operation allows you to configure these properties directly in the message.

When you need to set a property for an outgoing message, you can use the `properties` element in the
message:

```xml
<anypoint-mq:publish config-ref="MQ_config" destination="${bridgeDestination}"
                     properties="#[{AUTH_TYPE: 'jwt', AUTH_TOKEN: attributes.queryParams.token}]">
    <anypoint-mq:body>#["bridged_" ++ payload]</anypoint-mq:body>
</anypoint-mq:publish>
```

## See Also

- [Anypoint MQ ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-listener)
