Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:31:02+00:00 2026-06-04T16:31:02+00:00

I am using Spring-AMQP to monitor a RabbitMQ message queue in a Play application.

  • 0

I am using Spring-AMQP to monitor a RabbitMQ message queue in a Play application.

The problem is I can not access my database from the listener code since the JPA context is not open in this scope.

I understand Play Framework manages the JPA context so that it is open when processing HTTP requests, but is there a way I can use JPA from outside Play controllers/jobs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:31:04+00:00Added an answer on June 4, 2026 at 4:31 pm

    Just found the answer was to use JPAPlugin!

    Example listener method:

    public void process(Message message) {
        JPAPlugin.startTx(false);
        boolean rollBack = false;
        try {
            // work with your models
            JPA.em().flush();
        } catch (RuntimeException e) {
            rollBack = true;
            // throw exception to prevent msg ACK, need to refine error handling :)
            throw e;
        } finally {
            JPAPlugin.closeTx(rollBack);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Spring 3.0 EL can we auto wire a property from a property file
Using Spring 3.0, I wrote an interface to hide from the application which template
When using spring security, specifically with @notation; what is the proper way to access
I am using spring/hibernate stand alone application. if i dont configure Transactions i am
I am using spring mvc in my application,when i created user i have to
Using Spring and Struts together gives no error message in the console, but only
I'm using spring 2.5 SimpleJdbcTemplate to access MySQL db. When I try to access
Using Spring, I can get all beans of a certain type that are currently
Using Spring : can jta-transaction-manager use id as name so that I can pass
I have my application using Spring MVC + Apache 2 tiles + Spring security,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.