23.2.5.3. マスターノード
すべてのインデックス更新操作は JMS キューから取得され、実行されます。マスターインデックスは定期的にコピーされます。
例23.7 JMS マスターの設定
(remote) master location where information is copied to local master location refresh every half hour appropriate directory provider
### master configuration
## DirectoryProvider
# (remote) master location where information is copied to
hibernate.search.default.sourceBase = /mnt/mastervolume/lucenedirs/mastercopy
# local master location
hibernate.search.default.indexBase = /Users/prod/lucenedirs
# refresh every half hour
hibernate.search.default.refresh = 1800
# appropriate directory provider
hibernate.search.default.directory_provider = filesystem-master
## Backend configuration
#Backend is the default lucene one
Hibernate Search フレームワーク設定の他に、JMS を介してインデックスが動作するよう、メッセージ駆動 Bean を作成および設定する必要があります。
例23.8 インデクシングキューの処理中のメッセージ駆動型 Bean
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/hibernatesearch"), @ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="1") } ) public class MDBSearchController extends AbstractJMSHibernateSearchController implements MessageListener { @PersistenceContext EntityManager em; //method retrieving the appropriate session protected Session getSession() { return (Session) em.getDelegate(); } //potentially close the session opened in #getSession(), not needed here protected void cleanSessionIfNeeded(Session session) } }
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",
propertyValue="queue/hibernatesearch"),
@ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="1")
} )
public class MDBSearchController extends AbstractJMSHibernateSearchController
implements MessageListener {
@PersistenceContext EntityManager em;
//method retrieving the appropriate session
protected Session getSession() {
return (Session) em.getDelegate();
}
//potentially close the session opened in #getSession(), not needed here
protected void cleanSessionIfNeeded(Session session)
}
}
この例では、Hibernate Search ソースコードで利用可能な抽象 JMS コントローラークラスを継承し、MDB を実装します。この実装は例として提供され、Java EE 以外のメッセージ駆動型 Bean を使用するよう調整できます。
getSession()
および cleanSessionIfNeeded()
の詳細は、「 AbstractJMSHibernateSearchController
's javadoc」を参照してください。