Created
February 28, 2025 15:27
-
-
Save jwmatthews/6607e03ad2d878978599e54d3263d443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Message-0 | |
================================ System Message ================================ | |
You are an experienced java developer, who specializes in migrating code from java-ee to quarkus | |
Message-1 | |
================================ Human Message ================================= | |
I will give you a java-ee file for which I want to take one step towards migrating to quarkus. | |
I will provide you with static source code analysis information highlighting an issue which needs to be addressed. | |
Fix all the issues described. Other problems will be solved in subsequent steps so it is unnecessary to handle them now. | |
Before attempting to migrate the code to quarkus reason through what changes are required and why. | |
Pay attention to changes you make and impacts to external dependencies in the pom.xml as well as changes to imports we need to consider. | |
Remember when updating or adding annotations that the class must be imported. | |
As you make changes that impact the pom.xml or imports, be sure you explain what needs to be updated. | |
After you have shared your step by step thinking, provide a full output of the updated file. | |
# Input information | |
## Input File | |
File name: "OrderServiceMDB.java" | |
Source file contents: | |
```java | |
package com.redhat.coolstore.service; | |
import javax.ejb.ActivationConfigProperty; | |
import javax.ejb.MessageDriven; | |
import jakarta.inject.Inject; | |
import javax.jms.JMSException; | |
import javax.jms.Message; | |
import javax.jms.MessageListener; | |
import javax.jms.TextMessage; | |
import com.redhat.coolstore.model.Order; | |
import com.redhat.coolstore.utils.Transformers; | |
@MessageDriven(name = "OrderServiceMDB", activationConfig = { | |
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "topic/orders"), | |
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), | |
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}) | |
public class OrderServiceMDB implements MessageListener { | |
@Inject | |
OrderService orderService; | |
@Inject | |
CatalogService catalogService; | |
@Override | |
public void onMessage(Message rcvMessage) { | |
System.out.println("\nMessage recd !"); | |
TextMessage msg = null; | |
try { | |
if (rcvMessage instanceof TextMessage) { | |
msg = (TextMessage) rcvMessage; | |
String orderStr = msg.getBody(String.class); | |
System.out.println("Received order: " + orderStr); | |
Order order = Transformers.jsonToOrder(orderStr); | |
System.out.println("Order object is " + order); | |
orderService.save(order); | |
order.getItemList().forEach(orderItem -> { | |
catalogService.updateInventoryItems(orderItem.getProductId(), orderItem.getQuantity()); | |
}); | |
} | |
} catch (JMSException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} | |
``` | |
## Issues | |
### incident 0 | |
incident to fix: "Enterprise Java Beans (EJBs) are not supported in Quarkus. CDI must be used. | |
Please replace the `@MessageDriven` annotation with a CDI scope annotation like `@ApplicationScoped`." | |
Line number: 14 | |
# Output Instructions | |
Structure your output in Markdown format such as: | |
## Reasoning | |
Write the step by step reasoning in this markdown section. If you are unsure of a step or reasoning, clearly state you are unsure and why. | |
## Updated java File | |
```java | |
// Write the updated file in this section. If the file should be removed, make the content of the updated file a comment explaining it should be removed. | |
``` | |
## Additional Information (optional) | |
If you have any additional details or steps that need to be performed, put it here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment