In the 19th century, substantial outmigration from Java was connected to the Hajj pilgrimage to Mecca. Indonesia was the country of origin of almost half the pilgrims who reached Mecca. Many pilgrims were robbed by Bedouins, or ended up as debt slaves in Mecca or elsewhere in the Arabian peninsula. During the 1872 Hajj (8 - 16 March), thousands were killed by the cholera. The Dutch opened a consulate in Jeddah to protect the pilgrims. Since then each candidate for the Hajj had to testify that he had at least 500 guilders with him and that his family had been taken care of. This did not change the fact that only half of the pilgrims returned to Java. In 1885, 10.000 Javanese lived in Mecca.
Read more? Ulbe Bosma, 'Migration and Colonial Enterprise in 19th century Java' in: Globalising Migration History (Leiden 2014)