{%- import "util.jinja.include" as util -%}
{%- set messagegroups = root.messagegroups %}
{% for messagegroupid, messagegroup in messagegroups.items() -%}
{%- set groupname = messagegroupid | pascal -%}
{%- set class_name = (groupname | strip_namespace) + "Producer" %}
# {{ project_name | pascal }} - AMQP JMS Producer

Auto-generated Java producer using JMS (Jakarta Messaging) API over AMQP 1.0.

## Overview

JMS 2.0 producer client for {{ groupname }} message group. Uses familiar JMS API with AMQP 1.0 transport.

## What is JMS?

**JMS (Jakarta Messaging Service)** is the Java standard API for messaging. JMS over AMQP provides:
- **Standard Java API** familiar to enterprise Java developers
- **AMQP 1.0 transport** for interoperability
- **Connection pooling** and resource management
- **Transaction support**

## Quick Start

### 1. Add Dependency

**Maven:**
```xml
<dependency>
    <groupId>{{ groupid }}</groupId>
    <artifactId>{{ project_name | snake }}</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>org.apache.qpid</groupId>
    <artifactId>qpid-jms-client</artifactId>
    <version>2.5.0</version>
</dependency>
```

### 2. Send Messages

```java
import {{ project_name | snake }}.{{ class_name }};

String connectionString = "amqp://localhost:5672";
String queueName = "events";

{{ class_name }} producer = new {{ class_name }}(connectionString, queueName);

{%- set first_message = messagegroup.messages.items() | first %}
{%- if first_message %}
{%- set messageid, message = first_message %}
{%- set messagename = messageid | pascal | strip_namespace %}
{%- set message_body_type = util.body_type(data_project_name, root, message) %}

{{ message_body_type }} data = new {{ message_body_type }}();
producer.send{{ messagename }}(data);
{%- endif %}

producer.close();
```

## Available Methods

{% for messageid, message in messagegroup.messages.items() -%}
{%- set messagename = messageid | pascal | strip_namespace %}
{%- set message_body_type = util.body_type(data_project_name, root, message) %}
### send{{ messagename }}

```java
void send{{ messagename }}({{ message_body_type }} data)
void send{{ messagename }}({{ message_body_type }} data, MessageOptions options)
```
{% if message.description %}
{{ message.description }}
{% endif %}

{% endfor %}

## JMS Message Properties

```java
MessageOptions options = new MessageOptions();
options.setJMSMessageId("unique-id");
options.setJMSCorrelationId("correlation-id");
options.setJMSExpiration(System.currentTimeMillis() + 300000);  // 5 min TTL
options.setJMSPriority(4);  // 0-9, default 4
options.setJMSDeliveryMode(DeliveryMode.PERSISTENT);

producer.sendEventName(data, options);
```

## Connection Pooling

```java
{{ class_name }} producer = {{ class_name }}.builder()
    .connectionString("amqp://host:5672")
    .queueName("events")
    .maxConnections(10)
    .build();
```

## Authentication

```java
{{ class_name }} producer = {{ class_name }}.builder()
    .connectionString("amqp://host:5672")
    .queueName("events")
    .username("user")
    .password("pass")
    .build();
```

## Transactions

```java
{{ class_name }} producer = {{ class_name }}.builder()
    .transacted(true)
    .build();

try {
    producer.sendEventName(data1);
    producer.sendEventName(data2);
    producer.commit();  // Both messages sent atomically
} catch (JMSException e) {
    producer.rollback();
}
```

## Error Handling

```java
try {
    producer.sendEventName(data);
} catch (JMSException e) {
    System.err.println("Send failed: " + e.getMessage());
}
```

## Learn More

- [Jakarta Messaging Specification](https://jakarta.ee/specifications/messaging/)
- [Apache Qpid JMS Client](https://qpid.apache.org/components/jms/)
- [xRegistry CLI Documentation](https://github.com/xregistry/codegen)

## Generated Code

Auto-generated by [xRegistry CLI](https://github.com/xregistry/codegen).
{% endfor %}
